omegga 1.17.2 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +7 -6
  2. package/dist/db/migrations/0001_shocking_the_captain.sql +4 -0
  3. package/dist/db/migrations/meta/0001_snapshot.json +753 -0
  4. package/dist/db/migrations/meta/_journal.json +7 -0
  5. package/dist/db/schema.js +10 -1
  6. package/dist/db/schema.js.map +1 -1
  7. package/dist/omegga/server.js +6 -4
  8. package/dist/omegga/server.js.map +1 -1
  9. package/dist/plugin.js.map +1 -1
  10. package/dist/webserver/backend/chatQuery.js +98 -0
  11. package/dist/webserver/backend/chatQuery.js.map +1 -0
  12. package/dist/webserver/backend/database.js +270 -5
  13. package/dist/webserver/backend/database.js.map +1 -1
  14. package/dist/webserver/backend/router/chat.js +21 -0
  15. package/dist/webserver/backend/router/chat.js.map +1 -1
  16. package/dist/webserver/backend/router/player.js +1 -0
  17. package/dist/webserver/backend/router/player.js.map +1 -1
  18. package/package.json +4 -3
  19. package/public/app.html +291 -48
  20. package/public/assets/IconShieldCheck-e9eEH-KF.js +2 -0
  21. package/public/assets/{IconWorld-DgiOjCuo.js → IconWorld-CMSFtQg-.js} +2 -2
  22. package/public/assets/IconWorldPlus-B3tINWGI.js +2 -0
  23. package/public/assets/IconX-Dnl42MJL.js +2 -0
  24. package/public/assets/app-Dfcj6I4Z.js +7 -0
  25. package/public/assets/auth-CNs90huc.js +2 -0
  26. package/public/assets/{index-B0LowBt1.js → index-B6mWKnn3.js} +2 -2
  27. package/public/assets/index-C6nSzQey.js +12 -0
  28. package/public/assets/{index-2cgXLhrt.js → index-NK6TBVas.js} +2 -2
  29. package/public/assets/shared/@components-DxLSzrzW.js +2 -0
  30. package/public/assets/shared/{@hooks-DlZ8TOOZ.js → @hooks-Df79JLiI.js} +2 -2
  31. package/public/assets/shared/@tabler_icons-react-CM_Q7eQ6.js +3 -0
  32. package/public/assets/shared/wouter-CPV7_rSk.js +2 -0
  33. package/public/auth.html +80 -5
  34. package/public/assets/IconShieldCheck-Bjlm8mX2.js +0 -2
  35. package/public/assets/IconWorldPlus-DJJNrT87.js +0 -2
  36. package/public/assets/IconX-CvmO0bbE.js +0 -2
  37. package/public/assets/app-Mh--ChqF.js +0 -7
  38. package/public/assets/auth-DQtYicf-.js +0 -2
  39. package/public/assets/index-BTSbuqTr.js +0 -12
  40. package/public/assets/shared/@components-DBMXoJMT.js +0 -2
  41. package/public/assets/shared/@tabler_icons-react-i-Q2c_A_.js +0 -3
  42. package/public/assets/shared/wouter-CUC1caxu.js +0 -2
@@ -0,0 +1,7 @@
1
+ import{c as id}from"./client-BT1QYH0O.js";import{j as e}from"./jsx-runtime-BX5r4UiA.js";import{r as C,a as pi}from"./index-CrN8I5Az.js";import{i as od,u as wr,m as ld,M as cd,a as ud,c as dd,f as hd,b as Fr,d as fd,e as pd,g as Ba,h as md,t as Y,j as ut,T as gd,S as te,N as ze,P as He,k as We,D as Br,l as nr,n as lt,o as mi,p as Ae,q as we,r as Pe,A as Ve,C as eu,s as tu,I as gi,v as vi,w as vd,U as Ur,L as yi,x as yd,y as Ua,z as ke,B as xd,E as bd,R as jd,F as Yt,G as wd,H as xi,Q as Sd}from"./index-C6nSzQey.js";import{L as xt,u as Le,a as st,b as _d,S as Sr,R as _e,c as Cd,d as Rd}from"./index-NK6TBVas.js";import{d as Me,i as Nd,h as ru,a as bi,b as nu,l as Pd,r as _r,c as Cr,e as Ed,f as Rr,g as $a,j as Nr,k as at,m as kd}from"./utils-Ds3ldd-U.js";import{useHasScope as ie,useRequireScope as dt,useIsMobile as Md,useRequireAnyScope as Od,useMobileInspector as Kt,useSaved as Dd,SavedSpan as Ad,SavedStatus as qd}from"./shared/@hooks-Df79JLiI.js";import{a as Xt}from"./index-CSV4ZXsq.js";import{$ as Ga,a as ht,b as su,c as Td,d as Na}from"./user-XF1UyJMA.js";import{$ as Ld,b as Id,L as xe,I as me,a as F,u as et,F as Oe,D as tt,M as ct,H as Xe,P as rt,T as au}from"./index-B6mWKnn3.js";import{useStore as Ne}from"./shared/@nanostores_react-DJPF1Eqx.js";import{_ as zd,a as ji,I as Hd,b as Pa}from"./IconShieldCheck-e9eEH-KF.js";import{b as De,I as iu}from"./IconX-Dnl42MJL.js";import{I as wi,a as Pr,b as Ea,c as Wd,d as Vt,e as bt,f as Fd,g as Si,h as ka,i as _i,j as ou,k as Ya,l as Ma,m as Ci,n as lu,o as cu,p as Ri,q as Bd,r as Ud,s as $d,t as Gd,u as uu,v as Yd,w as Oa,x as Ni,y as Kd,z as Xd,A as Qt,B as Vd,C as du,D as hu,E as Qd,F as hr,G as fu,H as pu,J as Jd,K as Zd,L as eh,M as th,N as rh,O as nh,P as sh,Q as ah,R as ih,S as mu,T as $r,U as Pi,V as gu,W as vu,X as oh,Y as lh,Z as ch}from"./IconWorldPlus-B3tINWGI.js";import{I as fr}from"./IconCheck-DOe3u7iH.js";import{I as nt,a as Ka,b as St,c as _t,d as yu,e as Er,f as pr,g as uh,h as dh,i as hh,j as Ei,k as fh}from"./IconWorld-CMSFtQg-.js";import{a as ph,g as Xa}from"./_commonjsHelpers-CE1G-McA.js";import{r as Fe}from"./index-D0OPOe3j.js";import{r as Va}from"./index-CtCtK5BX.js";import"./jsx-runtime-DldvXD6N.js";import"./index-CJ4e7_2M.js";function mh(...t){const n=!Array.isArray(t[0]),r=n?0:-1,s=t[0+r],a=t[1+r],i=t[2+r],o=t[3+r],u=od(a,i,o);return n?u(s):u}function xu(t){const n=wr(()=>ld(t)),{isStatic:r}=C.useContext(cd);if(r){const[,s]=C.useState(t);C.useEffect(()=>n.on("change",s),[])}return n}function bu(t,n){const r=xu(n()),s=()=>r.set(n());return s(),ud(()=>{const a=()=>hd.preRender(s,!1,!0),i=t.map(o=>o.on("change",a));return()=>{i.forEach(o=>o()),dd(s)}}),r}function gh(t){Fr.current=[],t();const n=bu(Fr.current,t);return Fr.current=void 0,n}function vh(t,n,r,s){if(typeof t=="function")return gh(t);const i=typeof n=="function"?n:mh(n,r,s),o=Array.isArray(t)?ki(t,i):ki([t],([v])=>i(v)),u=Array.isArray(t)?void 0:t.accelerate;return u&&!u.isTransformed&&typeof n!="function"&&Array.isArray(r)&&s?.clamp!==!1&&(o.accelerate={...u,times:n,keyframes:r,isTransformed:!0}),o}function ki(t,n){const r=wr(()=>[]);return bu(t,()=>{r.length=0;const s=t.length;for(let a=0;a<s;a++)r[a]=t[a].get();return n(r)})}const ju=C.createContext(null);function yh(t,n,r,s){if(!s)return t;const a=t.findIndex(_=>_.value===n);if(a===-1)return t;const i=s>0?1:-1,o=t[a+i];if(!o)return t;const u=t[a],v=o.layout,x=fd(v.min,v.max,.5);return i===1&&u.layout.max+r>x||i===-1&&u.layout.min+r<x?pd(t,a,a+i):t}function xh({children:t,as:n="ul",axis:r="y",onReorder:s,values:a,...i},o){const u=wr(()=>Ba[n]),v=[],x=C.useRef(!1),_=C.useRef(null),b={axis:r,groupRef:_,registerItem:(w,m)=>{const l=v.findIndex(c=>w===c.value);l!==-1?v[l].layout=m[r]:v.push({value:w,layout:m[r]}),v.sort(jh)},updateOrder:(w,m,l)=>{if(x.current)return;const c=yh(v,w,m,l);if(v!==c){x.current=!0;const d=[...a];for(let h=0;h<c.length;h++)if(v[h].value!==c[h].value){const y=a.indexOf(v[h].value),p=a.indexOf(c[h].value);y!==-1&&p!==-1&&([d[y],d[p]]=[d[p],d[y]]);break}s(d)}}};C.useEffect(()=>{x.current=!1});const j=w=>{_.current=w,typeof o=="function"?o(w):o&&(o.current=w)},P={overflowAnchor:"none",...i.style};return e.jsx(u,{...i,style:P,ref:j,ignoreStrict:!0,children:e.jsx(ju.Provider,{value:b,children:t})})}const bh=C.forwardRef(xh);function jh(t,n){return t.layout.min-n.layout.min}const sr=50,Mi=25,wh=new Set(["auto","scroll"]),Ut=new WeakMap,$t=new WeakMap;let Ht=null;function Sh(){if(Ht){const t=Da(Ht,"y");t&&($t.delete(t),Ut.delete(t));const n=Da(Ht,"x");n&&n!==t&&($t.delete(n),Ut.delete(n)),Ht=null}}function _h(t,n){const r=getComputedStyle(t),s=n==="x"?r.overflowX:r.overflowY,a=t===document.body||t===document.documentElement;return wh.has(s)||a}function Da(t,n){let r=t?.parentElement;for(;r;){if(_h(r,n))return r;r=r.parentElement}return null}function Ch(t,n,r){const s=n.getBoundingClientRect(),a=r==="x"?Math.max(0,s.left):Math.max(0,s.top),i=r==="x"?Math.min(window.innerWidth,s.right):Math.min(window.innerHeight,s.bottom),o=t-a,u=i-t;if(o<sr){const v=1-o/sr;return{amount:-Mi*v*v,edge:"start"}}else if(u<sr){const v=1-u/sr;return{amount:Mi*v*v,edge:"end"}}return{amount:0,edge:null}}function Rh(t,n,r,s){if(!t)return;Ht=t;const a=Da(t,r);if(!a)return;const i=n-(r==="x"?window.scrollX:window.scrollY),{amount:o,edge:u}=Ch(i,a,r);if(u===null){$t.delete(a),Ut.delete(a);return}const v=$t.get(a),x=a===document.body||a===document.documentElement;if(v!==u){if(!(u==="start"&&s<0||u==="end"&&s>0))return;$t.set(a,u);const b=r==="x"?a.scrollWidth-(x?window.innerWidth:a.clientWidth):a.scrollHeight-(x?window.innerHeight:a.clientHeight);Ut.set(a,b)}if(o>0){const _=Ut.get(a);if((r==="x"?x?window.scrollX:a.scrollLeft:x?window.scrollY:a.scrollTop)>=_)return}r==="x"?x?window.scrollBy({left:o}):a.scrollLeft+=o:x?window.scrollBy({top:o}):a.scrollTop+=o}function Oi(t,n=0){return md(t)?t:xu(n)}function Nh({children:t,style:n={},value:r,as:s="li",onDrag:a,onDragEnd:i,layout:o=!0,...u},v){const x=wr(()=>Ba[s]),_=C.useContext(ju),b={x:Oi(n.x),y:Oi(n.y)},j=vh([b.x,b.y],([c,d])=>c||d?1:"unset"),{axis:P,registerItem:w,updateOrder:m,groupRef:l}=_;return e.jsx(x,{drag:P,...u,dragSnapToOrigin:!0,style:{...n,x:b.x,y:b.y,zIndex:j},layout:o,onDrag:(c,d)=>{const{velocity:h,point:y}=d,p=b[P].get();m(r,p,h[P]),Rh(l.current,y[P],P,h[P]),a&&a(c,d)},onDragEnd:(c,d)=>{Sh(),i&&i(c,d)},onLayoutMeasure:c=>{w(r,c)},ref:v,ignoreStrict:!0,children:t})}const Ph=C.forwardRef(Nh);let mr=-1,gr=-1,vr=!1,Gt=null,Aa,qa,Qa=!1,Ja=0;const Eh=400,kh=300,Mh=300,Oh=700,Ie=document.createElement("div");Object.assign(Ie.style,{position:"fixed",left:"-1000px",top:"-1000px",border:"2px solid black",background:"white",fontFamily:"Glacial Indifference",fontWeight:"bold",fontSize:"16px",padding:"8px",maxWidth:"300px",overflowWrap:"anywhere",zIndex:"100000",borderRadius:"8px",pointerEvents:"none",opacity:0,transition:"opacity .2s ease"});Ie.innerText="";document.body.appendChild(Ie);const Pt=8;function Ta(t,n){const r=document.documentElement.clientWidth,s=document.documentElement.clientHeight;Ie.style.maxWidth=Math.min(300,r-Pt*2)+"px";const a=Ie.clientWidth,i=Ie.clientHeight,o=t+(t<r/2?16:-16-a),u=n+(n<s/2?16:-16-i);Object.assign(Ie.style,{left:Math.max(Pt,Math.min(o,r-a-Pt))+"px",top:Math.max(Pt,Math.min(u,s-i-Pt))+"px"})}function Za(t){if(!t||!t.getAttribute)return;const n=t.getAttribute("data-tooltip");return n||Za(t.parentNode??null)}function wu(t,n,r,s){if(clearTimeout(qa),vr&&Gt===t){Ta(n,r);return}Gt!==t&&(clearTimeout(Aa),Gt=t,Aa=setTimeout(()=>{Ie.innerText=t,Ta(n,r),Ie.style.opacity="1",vr=!0},s))}function kr(){clearTimeout(Aa),Gt!==null&&(Gt=null,Ie.style.opacity="0",clearTimeout(qa),qa=setTimeout(()=>{vr=!1,Object.assign(Ie.style,{left:"-1000px",top:"-1000px"})},Mh))}document.body.addEventListener("mousemove",t=>{Date.now()<Ja||(Qa=!1,mr=t.clientX,gr=t.clientY,vr&&Ta(mr,gr))});function Dh(){if(Qa||Date.now()<Ja)return;const t=document.elementFromPoint(mr,gr),n=Za(t);n?wu(n,mr,gr,Eh):kr()}document.body.addEventListener("touchstart",t=>{Qa=!0;const n=t.touches[0];if(!n)return;const r=document.elementFromPoint(n.clientX,n.clientY),s=Za(r);s?wu(s,n.clientX,n.clientY,kh):kr()},{passive:!0});document.body.addEventListener("touchmove",()=>kr(),{passive:!0});function Su(){Ja=Date.now()+Oh,kr()}document.body.addEventListener("touchend",Su);document.body.addEventListener("touchcancel",Su);setInterval(Dh,100);const Di=document.documentElement,gt=window.visualViewport,Ah=150;function Gr(){if(!gt)return;Di.style.setProperty("--vvh",`${Math.round(gt.height)}px`);const t=window.innerHeight-gt.height;Di.classList.toggle("keyboard-open",t>Ah)}gt&&(gt.addEventListener("resize",Gr),gt.addEventListener("scroll",Gr),Gr());const Ai=Xt(!1),qi=Xt(!1),qh=()=>{const{data:t,status:n,error:r}=Y.session.info.useQuery(),s=ie(te.ServerStatus),{data:a}=Y.server.status.useQuery(void 0,{enabled:s}),[i,o]=C.useState(null);Y.server.onPlayerCount.useSubscription(void 0,{enabled:s,onError:ut,onData:o});const u=!!a,v=a?.serverName??null,x=a?.players?.length??null;return C.useEffect(()=>{if(!s||!u){document.title="Omegga";return}const _=i??x,b=v??"Brickadia Server";document.title=_!=null?`${b} - ${_}`:b},[s,u,v,x,i]),C.useEffect(()=>{n==="success"&&t?(Ga.set(t),Ld.set(t.version),Id.set(t.brickadiaVersion),ht.set(t.user),su.set(t.user.resolvedScopes??{}),Td.set(t.canLogOut),Ai.set(!0),qi.set(!1)):n==="error"&&(Ai.set(!1),qi.set(!0),r instanceof gd&&r.data?.code==="UNAUTHORIZED"&&location.reload())},[t,n]),null},Th=()=>e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Not Found"}),e.jsx(He,{children:e.jsx(We,{})})]}),Yr=({error:t})=>t?e.jsx("div",{className:"mfa-error",children:t}):null,Lh=()=>{const t=Y.mfa.status.useQuery(),n=Y.mfa.totp.setup.useMutation(),r=Y.mfa.totp.enable.useMutation(),s=Y.mfa.totp.disable.useMutation(),a=Y.mfa.passkey.registerOptions.useMutation(),i=Y.mfa.passkey.register.useMutation(),o=Y.mfa.passkey.remove.useMutation(),u=Y.mfa.recoveryCodes.generate.useMutation(),[v,x]=C.useState(null),[_,b]=C.useState(""),[j,P]=C.useState(""),[w,m]=C.useState(""),[l,c]=C.useState(""),[d,h]=C.useState(""),[y,p]=C.useState(null),[g,f]=C.useState(""),[S,N]=C.useState(""),[O,R]=C.useState(""),[M,D]=C.useState(!1),q=typeof window<"u"&&!!window.PublicKeyCredential&&(location.protocol==="https:"||location.hostname==="localhost"),T=C.useCallback(async()=>{if(!j)return;f(""),D(!0);const Q=await n.mutateAsync({password:j});D(!1),"error"in Q&&Q.error?f(Q.error):"secret"in Q&&(x(Q),b(""),P(""))},[j]),z=C.useCallback(async()=>{if(!v)return;f(""),D(!0);const Q=await r.mutateAsync({code:_});D(!1),Q?f(Q):(x(null),b(""),t.refetch())},[v,_]),A=C.useCallback(async()=>{if(!j)return;f(""),D(!0);const Q=await s.mutateAsync({password:j});D(!1),Q?f(Q):(P(""),t.refetch())},[j]),U=C.useCallback(async()=>{N(""),D(!0);try{const Q=await a.mutateAsync(),{startRegistration:he}=await zd(async()=>{const{startRegistration:fe}=await import("./index-BDkarAkX.js");return{startRegistration:fe}},[]),B=await he({optionsJSON:Q}),oe=await i.mutateAsync({credential:B,name:d||"Passkey"});oe?N(oe):(h(""),t.refetch())}catch(Q){Q?.name!=="NotAllowedError"&&N(Q?.message||"Registration failed")}D(!1)},[d]),X=C.useCallback(async Q=>{if(!w){N("Enter your password to remove a passkey");return}N(""),D(!0);const he=await o.mutateAsync({id:Q,password:w});he?N(he):(m(""),t.refetch()),D(!1)},[w]),V=C.useCallback(async()=>{if(!l)return;R(""),D(!0);const Q=await u.mutateAsync({password:l});"error"in Q&&Q.error?R(Q.error):"codes"in Q&&(p(Q.codes),c(""),t.refetch()),D(!1)},[l]),le=C.useCallback(()=>{y&&navigator.clipboard.writeText(y.join(`
2
+ `))},[y]);if(t.isLoading)return e.jsx(xe,{active:!0,size:"huge",children:"Loading MFA"});const de=t.data;return e.jsxs("div",{className:"mfa-manager",children:[e.jsx("div",{className:"section-header",children:"Authenticator App"}),e.jsxs("div",{className:"stats",children:[e.jsx(Yr,{error:g}),de?.totpEnabled&&!v&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"stat",children:[e.jsx(ji,{size:16})," TOTP is enabled."]}),e.jsxs("div",{className:"mfa-actions",children:[e.jsx(me,{placeholder:"Password to disable",type:"password",value:j,onChange:P,onSubmit:j&&!M?A:void 0}),e.jsxs(F,{warn:!0,boxy:!0,disabled:!j||M,onClick:A,children:[e.jsx(De,{})," Disable"]})]})]}),!de?.totpEnabled&&!v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"stat",children:"TOTP is not configured."}),e.jsxs("div",{className:"mfa-actions",children:[e.jsx(me,{placeholder:"Password to set up",type:"password",value:j,onChange:P,onSubmit:j&&!M?T:void 0}),e.jsxs(F,{main:!0,boxy:!0,disabled:!j||M,onClick:T,children:[e.jsx(ji,{})," Set Up"]})]})]}),v&&e.jsxs("div",{className:"totp-setup",children:[e.jsx("div",{className:"stat",children:"Scan this QR code with your authenticator app:"}),e.jsx("img",{className:"qr-code",src:v.qrCode,alt:"TOTP QR Code"}),e.jsxs("div",{className:"stat manual-secret",children:[e.jsx("b",{children:"Manual entry:"})," ",e.jsx("code",{children:v.secret}),e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Copy secret",onClick:()=>navigator.clipboard.writeText(v.secret),children:e.jsx(wi,{})})]}),e.jsxs("div",{className:"mfa-actions",children:[e.jsx(me,{placeholder:"6-digit code",type:"text",value:_,onChange:b,onSubmit:_&&!M?z:void 0}),e.jsxs(F,{main:!0,boxy:!0,disabled:!_||M,onClick:z,children:[e.jsx(fr,{})," Verify"]}),e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>{x(null),f("")},children:[e.jsx(De,{})," Cancel"]})]})]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-header",children:"Passkeys"}),e.jsxs("div",{className:"stats",children:[e.jsx(Yr,{error:S}),de?.passkeys?.length?e.jsx("div",{className:"passkey-list",children:de.passkeys.map(Q=>e.jsxs("div",{className:"passkey-item",children:[e.jsxs("span",{className:"passkey-name",children:[e.jsx(Hd,{size:16})," ",Q.name]}),e.jsxs("span",{className:"passkey-meta",children:["Added ",new Date(Q.created).toLocaleDateString()]}),e.jsx(F,{icon:!0,error:!0,disabled:M,"data-tooltip":"Remove passkey",onClick:()=>X(Q.id),children:e.jsx(Pr,{})})]},Q.id))}):e.jsx("div",{className:"stat",children:"No passkeys registered."}),e.jsxs("div",{className:"mfa-actions",children:[e.jsx(me,{placeholder:"Passkey name",type:"text",value:d,onChange:h}),e.jsxs(F,{main:!0,boxy:!0,disabled:M,onClick:U,children:[e.jsx(nt,{})," Add Passkey"]})]}),de?.passkeys?.length?e.jsx("div",{className:"mfa-actions",children:e.jsx(me,{placeholder:"Password to remove",type:"password",value:w,onChange:m})}):e.jsx("div",{className:"stat note",children:"Passkeys may not work with IP addresses. Use a domain name for reliable passkey support."})]})]}),e.jsx("div",{className:"section-header",children:"Recovery Codes"}),e.jsxs("div",{className:"stats",children:[e.jsx(Yr,{error:O}),y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"stat",children:"Save these codes. They will not be shown again."}),e.jsx("div",{className:"recovery-grid",children:y.map((Q,he)=>e.jsx("code",{children:Q},he))}),e.jsxs("div",{className:"mfa-actions",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:le,children:[e.jsx(wi,{})," Copy"]}),e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>p(null),children:[e.jsx(fr,{})," Done"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"stat",children:de?.hasRecoveryCodes?"Recovery codes are configured.":"No recovery codes generated."}),e.jsxs("div",{className:"mfa-actions",children:[e.jsx(me,{placeholder:"Password",type:"password",value:l,onChange:c,onSubmit:l&&!M?V:void 0}),e.jsxs(F,{warn:!!de?.hasRecoveryCodes,main:!de?.hasRecoveryCodes,boxy:!0,disabled:!l||M,onClick:V,children:[e.jsx(Pa,{})," ",de?.hasRecoveryCodes?"Regenerate":"Generate"]})]})]})]})]})};function _u(...t){let n="off";const r={},s={},a={off:0,read:1,all:2},i={none:0,read:1,all:2};for(const o of t){(a[o.root]??0)>(a[n]??0)&&(n=o.root);for(const[u,v]of Object.entries(o.domains??{}))(i[v]??0)>(i[r[u]]??0)&&(r[u]=v);for(const[u,v]of Object.entries(o.scopes??{}))v&&(s[u]=!0)}return{root:n,domains:r,scopes:s}}function Ke(t){const n={};for(const[r,s]of Object.entries(lt)){if(t.root==="all"){n[r]=!0;continue}if(t.root==="read"&&s.readOnly){n[r]=!0;continue}const a=t.domains[s.domain];if(a==="all"){n[r]=!0;continue}if(a==="read"&&s.readOnly){n[r]=!0;continue}n[r]=t.scopes[r]??!1}return n}function Ti(t,n){const r=Ke(t),s=Ke(n);return Object.keys(r).some(a=>r[a]&&!s[a])}function Li(t,n){const r=Ke(t);return Object.keys(r).some(s=>r[s]&&!n[s])}const Ih=[{value:"all",label:"All"},{value:"read",label:"Read Only"},{value:"off",label:"Manual"}],zh=[{value:"all",label:"All"},{value:"read",label:"Read Only"},{value:"none",label:"Manual"}];function Ii({value:t,options:n,onChange:r,disabled:s,disabledOptions:a}){return e.jsx("div",{className:`level-picker ${s?"dimmed":""}`,children:n.map((i,o)=>{const u=s||a?.has(i.value);return e.jsx("button",{className:["level-option",t===i.value?"active":"",`level-${i.value}`,o===0?"first":"",o===n.length-1?"last":""].filter(Boolean).join(" "),onClick:()=>{u||t===i.value||r(i.value)},disabled:!!u,children:i.label},i.value)})})}const yr=({perms:t,onChange:n,defaultPerms:r,disabled:s,actorScopes:a})=>{const[i,o]=C.useState({}),[u,v]=C.useState(""),x=u.toLowerCase(),_=x.length>0,b=!n,j=t.root!=="off",P=C.useMemo(()=>{if(!a)return;const S=new Set;for(const N of["all","read","off"]){if(N===t.root)continue;const O=N!=="off"?{root:N,domains:{},scopes:{}}:{...t,root:N};(Li(O,a)||Ti(t,O))&&S.add(N)}return S.size>=2&&S.add(t.root),S.size>0?S:void 0},[a,t]),w=C.useMemo(()=>{if(!a)return{};const S={};for(const N of Br){const O=t.domains[N]??"none",R=new Set;for(const M of["all","read","none"]){if(M===O)continue;const D={...t.domains},q={...t.scopes};if(M!=="none"){D[N]=M;for(const z of nr[N]??[])delete q[z]}else delete D[N];const T={...t,domains:D,scopes:q};(Li(T,a)||Ti(t,T))&&R.add(M)}R.size>=2&&R.add(O),R.size>0&&(S[N]=R)}return S},[a,t]),m=Object.keys(lt),l=m.length,c=C.useMemo(()=>{if(t.root==="all")return l;let S=0;for(const N of m){const O=lt[N];if(!O)continue;if(t.root==="read"&&O.readOnly){S++;continue}const R=t.domains[O.domain];if(R==="all"){S++;continue}if(R==="read"&&O.readOnly){S++;continue}t.scopes[N]&&S++}return S},[t]),d=S=>{n?.(S!=="off"?{...t,root:S,domains:{},scopes:{}}:{...t,root:S})},h=(S,N)=>{const O={...t.domains},R={...t.scopes};if(N!=="none"){O[S]=N;for(const M of nr[S]??[])delete R[M]}else delete O[S];n?.({...t,domains:O,scopes:R})},y=(S,N)=>{const O={...t.scopes};N?O[S]=!0:delete O[S],n?.({...t,scopes:O})},p=S=>o(N=>({...N,[S]:N[S]===!1})),g=S=>{if(!r)return null;const N=lt[S];if(!N)return null;if(r.root==="all")return!0;if(r.root==="read")return N.readOnly;const O=r.domains[N.domain];return O==="all"?!0:O==="read"?N.readOnly:r.scopes[S]??!1},f=C.useMemo(()=>{if(!_)return null;const S=new RegExp(x.split(/\s+/).filter(Boolean).map(R=>`(?=.*${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})`).join(""),"i"),N=R=>S.test(R),O={};for(const R of Br){const D=(nr[R]??[]).filter(q=>{const T=lt[q];return N(q)||N(mi[R]??"")||N(T?.description??"")});D.length>0&&(O[R]=D)}return O},[x,_]);return e.jsxs("div",{className:"permission-editor",children:[e.jsx("div",{className:"perm-search",children:e.jsx(me,{type:"text",placeholder:"Search Permissions...",value:u,onChange:v})}),!_&&e.jsxs("div",{className:"perm-row root-row",children:[e.jsx("span",{className:"perm-label root-label",children:"Everything"}),e.jsxs("span",{className:"scope-count",children:[c,"/",l]}),e.jsx(Ii,{value:t.root,options:Ih,onChange:d,disabled:s||b,disabledOptions:P})]}),Br.map(S=>{const N=t.domains[S],O=j||N==="all"||N==="read",R=nr[S]??[],M=_?f?.[S]??[]:R;if(_&&M.length===0)return null;const D=_||i[S]!==!1,q=t.root==="all"||N==="all"?R.length:t.root==="read"||N==="read"?R.filter(T=>lt[T]?.readOnly||t.scopes[T]).length:R.filter(T=>t.scopes[T]).length;return e.jsxs("div",{className:"perm-domain",children:[e.jsxs("div",{className:"perm-row domain-row",children:[e.jsxs("span",{className:"perm-label domain-label",onClick:()=>p(S),children:[D?e.jsx(Ea,{size:16}):e.jsx(Wd,{size:16})," ",mi[S]]}),e.jsxs("span",{className:"scope-count",children:[q,"/",R.length]}),e.jsx(Ii,{value:N??"none",options:zh,onChange:T=>h(S,T),disabled:s||b||j,disabledOptions:w[S]})]}),D&&M.map((T,z)=>{const A=lt[T],U=t.scopes[T]??!1,X=g(T);return e.jsxs("div",{className:`perm-row scope-row ${z%2===0?"even":"odd"}`,children:[e.jsxs("div",{className:"scope-info",children:[e.jsxs("span",{className:"scope-name",children:[e.jsx("span",{className:`scope-badge ${A?.readOnly?"read":"write"}`,"data-tooltip":A?.readOnly?"Read-only":"Read/Write",children:A?.readOnly?"R":"W"}),T.split(".").slice(1).join(".")]}),e.jsx("span",{className:"scope-desc",children:A?.description})]}),e.jsxs("div",{className:"scope-controls",children:[X===!0&&e.jsx("span",{className:"inherited on","data-tooltip":"Granted by defaults",children:e.jsx(fr,{size:14})}),e.jsx(Ae,{value:U,onChange:V=>y(T,V),disabled:s||b||O||a&&(U||!a[T])})]})]},T)})]},S)})]})},Hh=({username:t,isSelf:n,roleIds:r})=>{const s=ie(te.UserGrantRole),a=ie(te.RoleList),i=Y.role.list.useQuery(void 0,{enabled:a}),o=Y.user.grantRole.useMutation(),u=Y.user.revokeRole.useMutation(),v=Y.useUtils(),[x,_]=C.useState(!1),b=C.useRef(null),j=C.useMemo(()=>i.data??[],[i.data]),P=C.useMemo(()=>j.filter(c=>r.includes(c.id)).sort((c,d)=>c.order-d.order),[j,r]),w=C.useMemo(()=>j.filter(c=>!r.includes(c.id)),[j,r]);C.useEffect(()=>{if(!x)return;function c(d){d.target&&!b.current?.contains(d.target)&&_(!1)}return document.addEventListener("click",c),()=>document.removeEventListener("click",c)},[x]);const m=async c=>{await o.mutateAsync({username:t,roleId:c}),n?v.user.self.invalidate():v.user.list.invalidate(),_(!1)},l=async c=>{await u.mutateAsync({username:t,roleId:c}),n?v.user.self.invalidate():v.user.list.invalidate()};return a?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-header",children:"Roles"}),e.jsxs("div",{className:"br-player-list",style:{padding:12,position:"relative",maxWidth:"calc(100% - 32px)",marginRight:16,alignItems:"stretch"},children:[P.map(c=>e.jsxs("div",{className:"br-player-item",children:[e.jsx(xt,{href:`/roles/${c.id}`,className:"selected",children:c.name}),s&&!n&&e.jsx(F,{icon:!0,warn:!0,"data-tooltip":"Revoke role",onClick:()=>l(c.id),children:e.jsx(Ka,{})})]},c.id)),P.length===0&&e.jsx("div",{className:"br-player-item muted-text",style:{fontWeight:"bold"},children:"No roles assigned"}),s&&!n&&w.length>0&&e.jsxs("div",{className:"player-search",ref:b,children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>_(!x),children:[e.jsx(nt,{size:16}),"Add Role"]}),x&&e.jsx("div",{className:"options",children:w.map(c=>e.jsx("div",{className:"option",onClick:()=>m(c.id),children:c.name},c.id))})]})]})]}):null},Cu=({selfUser:t})=>{const[n,r]=Le("/users/:id"),[s,a]=st(),i=Ne(ht),o=Ne(su),u=ie(te.UserPermissions),v=ie(te.UserBan),x=ie(te.UserDelete),_=ie(te.UserPasswd),b=ie(te.UserReadMfa),j=ie(te.UserResetMfa),P=!!t,w=t??r?.id??"",m=Y.user.list.useQuery(void 0,{enabled:!P}),l=Y.user.self.useQuery(void 0,{enabled:P}),c=C.useMemo(()=>P?l.data??null:m.data?m.data.users.find(se=>se.username===w)??null:null,[P,l.data,m.data,w]),d=P?l.isLoading:m.isLoading,h=Y.role.defaultPermissions.get.useQuery(void 0,{enabled:u}),y=Y.user.permissions.useMutation(),p=Y.user.ban.useMutation(),g=Y.user.delete.useMutation(),f=Y.user.passwd.useMutation(),S=Y.user.resetMfa.useMutation(),N=Y.user.grantOwner.useMutation(),O=et(),R=et(),M=et(),[D,q]=C.useState(null),[T,z]=C.useState(!1),[A,U]=C.useState(""),[X,V]=C.useState(!1),[le,de]=C.useState(!1),[Q,he]=C.useState(!1),[B,oe]=C.useState(""),[fe,G]=C.useState(""),[ne,ce]=C.useState(""),[E,k]=C.useState(!1),[I,W]=C.useState(!1),[J,K]=C.useState(""),[Z,re]=C.useState(""),[ae,pe]=C.useState(""),Se=!!i?.isOwner,H=!!Y.mfa.status.useQuery(void 0,{enabled:Se&&!P}).data?.totpEnabled;C.useEffect(()=>{if(c){const se=c.permissions?.root;q({root:se==="all"||se==="read"?se:"off",domains:c.permissions?.domains??{},scopes:c.permissions?.scopes??{}})}else q(null)},[c?.username,c?.permissions]),C.useEffect(()=>{!P&&!d&&!c&&w&&a("/users")},[P,d,c,w]);const ee=Y.useUtils(),be=C.useCallback(async()=>{if(!(!D||!w)){z(!0),U("");try{const se=await y.mutateAsync({username:w,permissions:D});se?U(se):(await ee.user.list.refetch(),P&&await l.refetch())}catch(se){U(se?.message||"Failed to save permissions")}z(!1)}},[D,w]),Ce=C.useMemo(()=>!D||!c?.permissions?!1:JSON.stringify(D)!==JSON.stringify(c.permissions),[D,c?.permissions]),Re=async se=>{const ye=se?"Disable":"Re-enable";if(!await O.prompt(e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:[ye," user ",e.jsx("b",{children:w}),"?"]}),e.jsx("p",{children:se?"Disabled users cannot sign in to the web UI.":"This will allow the user to sign in again."})]})))return;const $e=await p.mutateAsync({username:w,banned:se});$e?console.error("Failed to ban user:",$e):m.refetch()},Ee=async()=>{if(!await R.prompt(e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Permanently delete user ",e.jsx("b",{children:w}),"?"]}),e.jsx("p",{children:"This will remove the account and all of its permissions. This action cannot be undone."})]})))return;const se=await g.mutateAsync({username:w});se?console.error("Failed to delete user:",se):(a("/users"),m.refetch(),Na.set(Na.get()+1))},pt=async()=>{if(!await M.prompt(e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Reset MFA for ",e.jsx("b",{children:w}),"?"]}),e.jsx("p",{children:"This will clear TOTP, passkeys, and recovery codes."})]})))return;const se=await S.mutateAsync({username:w});se?console.error("Failed to reset MFA:",se):P?l.refetch():m.refetch()},mt=()=>{k(!1),K(""),re(""),pe("")},Rt=async()=>{K(""),W(!0);try{const se=await N.mutateAsync({username:w,password:Z,code:ae||void 0});W(!1),se?K(se):(mt(),m.refetch())}catch(se){W(!1),K(se?.message||"Failed to grant ownership")}},Jt=async()=>{if(oe(""),fe===ne){he(!0);try{const se=await f.mutateAsync({username:w,password:fe});he(!1),se?oe(se):(de(!1),G(""),ce(""))}catch{he(!1)}}},Zt=(i?.username||"Admin")===(w||"Admin"),er=c&&(c.totpEnabled||(c.passkeyCount??0)>0),tr=Se&&!c?.isBanned,$=c&&!c.isOwner&&!Zt&&(v||x||_||j&&er||tr),ue=h.data?{root:h.data.root,domains:h.data.domains,scopes:h.data.scopes}:null,ve=Date.now();return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"player-inspector-container",children:[e.jsxs(we,{attached:!0,children:[c?.username||(P?"Account":"SELECT A USER"),e.jsx("span",{style:{flex:1}}),c&&u&&!c.isOwner&&e.jsxs(F,{normal:!0,disabled:T||!Ce,onClick:be,"data-tooltip":"Save Permissions",children:[e.jsx(Vt,{}),"Save"]})]}),e.jsx("div",{className:"player-inspector",children:e.jsxs("div",{className:"player-view",children:[e.jsx(xe,{active:d,size:"huge",children:"Loading User"}),e.jsx("div",{className:"player-info",children:!d&&c&&e.jsxs(Pe,{children:[e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Username:"})," ",c.username||"Admin"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Owner:"})," ",c.isOwner?"Yes":"No"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Disabled:"})," ",c.isBanned?"Yes":"No"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Last Active:"})," ",c.lastOnline?Me(ve-c.lastOnline)+" ago":"Never"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Created:"})," ",Me(ve-c.created)," ago"]}),!Zt&&b&&e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"MFA:"})," ",c.totpEnabled||(c.passkeyCount??0)>0?[c.totpEnabled&&"TOTP",(c.passkeyCount??0)>0&&`${c.passkeyCount??0} passkey(s)`].filter(Boolean).join(" + "):"Not configured"]})]}),P&&e.jsx(Lh,{}),!c.isOwner&&e.jsx(Hh,{username:w,isSelf:P,roleIds:c.roles??[]}),u&&!c.isOwner&&D&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-header",children:"Permissions"}),A&&e.jsx("div",{className:"perm-error",children:A}),e.jsx(yr,{perms:D,onChange:q,defaultPerms:ue,actorScopes:i?.isOwner?void 0:o})]}),c.isOwner&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"section-header",children:"Permissions"}),e.jsx(yr,{perms:{root:"all",domains:{},scopes:{}},onChange:()=>{},disabled:!0})]})]})})]})}),$&&e.jsxs(Oe,{attached:!0,children:[e.jsx("span",{style:{flex:1}}),e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>V(!X),children:[X?e.jsx(St,{}):e.jsx(_t,{}),"Actions"]}),e.jsxs(Ve,{visible:X,direction:"up",className:"widgets-list widgets-list-up",children:[_&&e.jsxs(F,{info:!0,onClick:()=>{V(!1),de(!0)},children:[e.jsx(Pa,{}),"Change Password"]}),v&&e.jsxs(F,{normal:!c.isBanned,warn:!!c.isBanned,onClick:()=>{V(!1),Re(!c.isBanned)},children:[e.jsx(bt,{}),c.isBanned?"Re-enable":"Disable"]}),j&&er&&e.jsxs(F,{warn:!0,onClick:()=>{V(!1),pt()},children:[e.jsx(Fd,{}),"Reset MFA"]}),tr&&e.jsxs(F,{warn:!0,onClick:()=>{V(!1),k(!0)},children:[e.jsx(Si,{}),"Grant Ownership"]}),x&&e.jsxs(F,{error:!0,onClick:()=>{V(!1),Ee()},children:[e.jsx(Pr,{}),"Delete"]})]})]})]})]}),O.children,R.children,M.children,e.jsxs(tt,{visible:le,children:[e.jsx(xe,{active:Q,size:"huge",children:"Submitting"}),e.jsxs(ct,{visible:!Q,children:[e.jsx(Xe,{children:"Change Password"}),e.jsxs(rt,{children:[e.jsxs("p",{children:["Set a new password for ",e.jsx("b",{children:w}),"."]}),B&&e.jsxs("p",{style:{color:"red"},children:["Error: ",B]})]}),e.jsxs("div",{className:"popout-inputs",children:[e.jsx(me,{placeholder:"new password",type:"password",value:fe,onChange:G}),e.jsx(me,{placeholder:"confirm new password",type:"password",value:ne,onChange:ce,onSubmit:fe.length&&ne===fe?Jt:void 0})]}),e.jsxs(Oe,{children:[e.jsxs(F,{main:!0,disabled:!fe.length||ne!==fe,onClick:Jt,children:[e.jsx(Pa,{}),"Update"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:()=>{de(!1),G(""),ce(""),oe("")},children:[e.jsx(De,{}),"Cancel"]})]})]})]}),e.jsxs(tt,{visible:E,children:[e.jsx(xe,{active:I,size:"huge",children:"Submitting"}),e.jsxs(ct,{visible:!I,children:[e.jsx(Xe,{children:"Grant Ownership"}),e.jsxs(rt,{children:[e.jsxs("p",{children:["Make ",e.jsx("b",{children:w})," an owner?"]}),e.jsx("p",{children:"Owners have full access to the web UI, bypass all permissions, and cannot be modified by other users. This cannot be undone from the web UI."}),e.jsxs("p",{children:["Confirm with your password",H?" and an MFA code":""," to continue."]}),J&&e.jsxs("p",{style:{color:"red"},children:["Error: ",J]})]}),e.jsxs("div",{className:"popout-inputs",children:[e.jsx(me,{placeholder:"your password",type:"password",value:Z,onChange:re,onSubmit:Z.length&&!H?Rt:void 0}),H&&e.jsx(me,{placeholder:"MFA code",type:"text",value:ae,onChange:pe,onSubmit:Z.length&&ae?Rt:void 0})]}),e.jsxs(Oe,{children:[e.jsxs(F,{warn:!0,disabled:!Z.length||H&&!ae,onClick:Rt,children:[e.jsx(Si,{}),"Grant"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:mt,children:[e.jsx(De,{}),"Cancel"]})]})]})]})]})},Wh=()=>{const t=Ne(ht),n=Y.user.passwd.useMutation(),r=Y.user.rename.useMutation(),s=Y.useUtils(),a=ie(te.UserRename),[i,o]=C.useState(!1),[u,v]=C.useState(!1),[x,_]=C.useState(!1),[b,j]=C.useState(""),[P,w]=C.useState(""),[m,l]=C.useState(""),[c,d]=C.useState(""),[h,y]=C.useState(!1),[p,g]=C.useState(!1),[f,S]=C.useState(""),[N,O]=C.useState(""),R=t?.username??"",M=()=>{v(!1),j(""),w(""),l(""),d("")},D=async()=>{if(j(""),m===c){_(!0);try{const U=await n.mutateAsync({username:R,password:m,currentPassword:P});if(_(!1),!U){M();return}j(U)}catch(U){console.error("error setting password",U),_(!1)}}},q=C.useMemo(()=>P.length>0&&m.length>0&&c===m,[P,m,c]),T=()=>{y(!1),S(""),O("")},z=async()=>{S(""),g(!0);try{const U=await r.mutateAsync({username:N});if(g(!1),U){S(U);return}T(),await Promise.all([s.session.info.refetch(),s.user.self.refetch()])}catch(U){console.error("error renaming user",U),g(!1)}},A=C.useMemo(()=>!!N.match(/^\w{1,32}$/)&&N!==R,[N,R]);return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Account",children:e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>o(!i),children:[i?e.jsx(_t,{}):e.jsx(St,{}),"Actions"]}),e.jsxs(Ve,{visible:i,children:[e.jsxs(F,{info:!0,onClick:()=>{o(!1),v(!0)},children:[e.jsx(ka,{}),"Change Password"]}),a&&e.jsxs(F,{info:!0,onClick:()=>{o(!1),y(!0)},children:[e.jsx(_i,{}),"Change Username"]})]})]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsx("div",{className:"generic-container players-container",children:e.jsx(Cu,{selfUser:R})}),e.jsxs(tt,{visible:u,children:[e.jsx(xe,{active:x,size:"huge",children:"Submitting"}),e.jsxs(ct,{visible:!x,children:[e.jsx(Xe,{children:"Change Password"}),e.jsx(rt,{children:b&&e.jsxs("p",{style:{color:"red"},children:["Error: ",b]})}),e.jsxs("div",{className:"popout-inputs",children:[e.jsx(me,{placeholder:"current password",type:"password",value:P,onChange:w}),e.jsx(me,{placeholder:"new password",type:"password",value:m,onChange:l}),e.jsx(me,{placeholder:"confirm new password",type:"password",value:c,onChange:d,onSubmit:q?D:void 0})]}),e.jsxs(Oe,{children:[e.jsxs(F,{main:!0,disabled:!q,onClick:D,children:[e.jsx(ka,{}),"Update"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:M,children:[e.jsx(De,{}),"Cancel"]})]})]})]}),e.jsxs(tt,{visible:h,children:[e.jsx(xe,{active:p,size:"huge",children:"Submitting"}),e.jsxs(ct,{visible:!p,children:[e.jsx(Xe,{children:"Change Username"}),e.jsxs(rt,{children:[e.jsx("p",{children:"Pick a new username. You will use it the next time you sign in."}),f&&e.jsxs("p",{style:{color:"red"},children:["Error: ",f]})]}),e.jsx("div",{className:"popout-inputs",children:e.jsx(me,{placeholder:"new username",type:"text",value:N,onChange:O,onSubmit:A?z:void 0})}),e.jsxs(Oe,{children:[e.jsxs(F,{main:!0,disabled:!A,onClick:z,children:[e.jsx(_i,{}),"Rename"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:T,children:[e.jsx(De,{}),"Cancel"]})]})]})]})]})]})},Fh=["msg","server","leave","join","crash"],Bh=["from","role","admin","before","after","action"],Uh=t=>{const n=[];let r="",s=!1;for(const a of t)a==='"'?s=!s:!s&&/\s/.test(a)?(r&&n.push(r),r=""):r+=a;return r&&n.push(r),n},Ru=t=>{const n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(n){const[,s,a,i]=n,o=new Date(Number(s),Number(a)-1,Number(i));return Number.isNaN(o.getTime())?void 0:o.getTime()}if(/^\d+$/.test(t))return Number(t);const r=new Date(t);return Number.isNaN(r.getTime())?void 0:r.getTime()},Nu=t=>{const n={terms:[],from:[],roles:[],admin:[],actions:[],filters:[]};for(const r of Uh(t)){const s=r.indexOf(":"),a=s>0?r.slice(0,s).toLowerCase():"",i=s>0?r.slice(s+1):"";if(!i){a==="admin"&&!n.adminAny?(n.adminAny=!0,n.filters.push({key:"admin",value:""})):r&&!Bh.includes(a)&&n.terms.push(r);continue}if(a==="from"){n.from.push(i),n.filters.push({key:"from",value:i});continue}if(a==="role"){n.roles.push(i),n.filters.push({key:"role",value:i});continue}if(a==="before"||a==="after"){const o=Ru(i);if(o===void 0){n.terms.push(r);continue}n[a]=o,n.filters.push({key:a,value:i});continue}if(a==="admin"){n.admin.push(i),n.filters.push({key:"admin",value:i});continue}if(a==="action"){const o=i.toLowerCase();if(!Fh.includes(o)){n.terms.push(r);continue}n.actions.includes(o)||(n.actions.push(o),n.filters.push({key:"action",value:o}));continue}n.terms.push(r)}return n},ei=t=>/\s/.test(t)?`"${t}"`:t,zi=t=>`${t.key}:${ei(t.value)}`,$h=t=>t.terms.length===0&&t.from.length===0&&t.roles.length===0&&t.before===void 0&&t.after===void 0&&t.actions.length===0&&t.admin.length===0&&!t.adminAny,Kr=()=>({entries:new Map,matches:new Set,closedBefore:new Set,closedAfter:new Set}),Pu=t=>({entries:new Map(t.entries),matches:new Set(t.matches),closedBefore:new Set(t.closedBefore),closedAfter:new Set(t.closedAfter)}),La=(t,n,r)=>{t.closedAfter.add(n),t.closedBefore.add(r)},Gh=(t,n)=>{const r=Pu(t);for(const{match:s,before:a,after:i}of n){r.entries.set(s._id,s),r.matches.add(s._id);const o=a[a.length-1];o?(r.entries.set(o._id,o),La(r,o._id,s._id)):r.closedBefore.add(s._id);const u=i[0];u?(r.entries.set(u._id,u),La(r,s._id,u._id)):r.closedAfter.add(s._id)}return r},Yh=(t,n,r,s,a)=>{const i=Pu(t);for(const u of s)i.entries.set(u._id,u);const o=r==="after"?[n,...s.map(u=>u._id)]:[...s.map(u=>u._id),n];for(let u=0;u<o.length-1;u++)La(i,o[u],o[u+1]);return s.length<a&&(r==="after"?i.closedAfter.add(o[o.length-1]):i.closedBefore.add(o[0])),i},Kh=(t,n)=>{const r=[...t.entries.keys()].sort((a,i)=>Number(a)-Number(i)),s=[];r.length>0&&!t.closedBefore.has(r[0])&&s.push({kind:"gap",id:r[0],direction:"before"});for(const a of r)s.push({kind:"entry",id:a,entry:t.entries.get(a),isMatch:t.matches.has(a)}),t.closedAfter.has(a)||s.push({kind:"gap",id:a,direction:"after"});return n?s.reverse():s},Eu="omegga:chat-search-history",Xh=8,Hi=[{key:"from",Icon:yu,title:"From a specific user",hint:"from: user"},{key:"role",Icon:Er,title:"From anyone with a role",hint:"role: Admin"},{key:"admin",Icon:ou,title:"Sent from omegga by an admin",hint:"admin: server"},{key:"action",Icon:Ya,title:"A specific kind of entry",hint:"action: msg, join, leave, server, crash"},{key:"before",Icon:Ma,title:"Sent before a date",hint:"before: 2026-01-01"},{key:"after",Icon:Ma,title:"Sent after a date",hint:"after: 2026-01-01"}],Vh=[{value:"msg",hint:"chat messages"},{value:"join",hint:"players joining"},{value:"leave",hint:"players leaving"},{value:"server",hint:"server announcements"},{value:"crash",hint:"server crashes"}],Qh=()=>{try{const t=JSON.parse(localStorage.getItem(Eu)??"[]");return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}},Wi=t=>{try{localStorage.setItem(Eu,JSON.stringify(t))}catch{}},ar=t=>{const n=Nu(t);return{badges:n.filters,text:n.terms.map(ei).join(" ")}},Jh=({value:t,onChange:n,onSubmit:r,onClear:s,senderNames:a})=>{const i=ie(te.PlayerList),[o,u]=C.useState(!1),[v,x]=C.useState(!1),[_,b]=C.useState(-1),[j,P]=C.useState(Qh),[w,m]=C.useState({}),[l,c]=C.useState(()=>ar(t).badges),[d,h]=C.useState(()=>ar(t).text),y=C.useRef(null),p=C.useRef(void 0),g=C.useRef(t);C.useEffect(()=>{if(t===g.current)return;const L=ar(t);c(L.badges),h(L.text),g.current=t},[t]);const f=(L,H)=>{x(!1),c(L),h(H);const ee=[...L.map(zi),H].filter(Boolean).join(" ");g.current=ee,n(ee)},S=d.split(/\s+/).pop()??"",N=S.indexOf(":"),O=N>0?S.slice(0,N).toLowerCase():"",R=N>0?S.slice(N+1):"",M=O==="from",D=O==="role",q=O==="admin",T=!R&&Hi.some(L=>L.key===O),z=O==="before"||O==="after",A=z?Ru(R):void 0,[U,X]=C.useState(null),V=C.useMemo(()=>{if(U)return U;const L=new Date(A??Date.now());return[L.getFullYear(),L.getMonth()]},[U,A]),[le,de]=V,Q=L=>{const H=new Date(le,de+L,1);return[H.getFullYear(),H.getMonth()]},[he,B]=C.useState("");C.useEffect(()=>{const L=setTimeout(()=>B(R),200);return()=>clearTimeout(L)},[R]);const{data:oe}=Y.player.list.useQuery({search:M?he:"",sort:"relevance"},{enabled:i&&o&&M}),{data:fe}=Y.player.roles.list.useQuery(void 0,{enabled:i&&o&&D}),G=ie(te.UserList),{data:ne}=Y.user.list.useQuery({search:"",sort:"name",direction:1,page:0},{enabled:G&&o&&q}),ce=C.useMemo(()=>{if(z)return[];const L=T?[{kind:"back",id:"back"}]:[];if(D){const ee=R.toLowerCase();return L.concat((fe??[]).filter(be=>be.name.toLowerCase().includes(ee)).slice(0,6).map(be=>({kind:"role",id:`role:${be.name}`,name:be.name})))}if(M)return L.concat((oe?.players??[]).slice(0,6).map(ee=>({kind:"player",id:ee.id,name:ee.name,displayName:ee.displayName})));if(q){const ee=R.toLowerCase(),be={value:"server",hint:"omegga's server console"},Ce=(ne?.users??[]).map(Re=>({value:Re.username,hint:Re.isOwner?"owner":"web user"}));return L.concat([be,...Ce].filter(Re=>Re.value.toLowerCase().includes(ee)).slice(0,6).map(Re=>({kind:"admin",id:`admin:${Re.value}`,...Re})))}if(O==="action")return L.concat(Vh.filter(ee=>ee.value.startsWith(R.toLowerCase())).map(ee=>({kind:"action",id:ee.value,...ee})));const H=Hi.filter(ee=>!S||N<0&&ee.key.startsWith(S.toLowerCase())).map(ee=>({kind:"filter",id:ee.key,...ee}));return!S&&j.length>0?[...H,...j.map(ee=>({kind:"recent",id:`recent:${ee}`,query:ee}))]:H},[M,D,q,T,ne,z,oe,fe,O,R,S,N,j]);C.useEffect(()=>b(-1),[S]);const E=L=>{const H=d.split(/(\s+)/);return H[H.length-1]=L,H.join("")},k=(L,H)=>{const ee=d.split(/(\s+)/);ee[ee.length-1]="",f([...l,{key:L,value:H}],ee.join(""))},I=L=>{if(L.kind==="filter")f(l,E(`${L.key}:`));else if(L.kind==="player")m(H=>({...H,[L.id]:L.name})),k("from",L.id);else if(L.kind==="action")k("action",L.value);else if(L.kind==="role")k("role",L.name);else if(L.kind==="admin")k("admin",L.value);else if(L.kind==="back")f(l,E(""));else if(L.kind==="recent"){const H=ar(L.query);f(H.badges,H.text),W(L.query);return}J()},W=L=>{const H=L.trim();if(H){const ee=[H,...j.filter(be=>be!==H)].slice(0,Xh);P(ee),Wi(ee)}x(!0),r(L)},J=()=>{clearTimeout(p.current),y.current?.focus(),u(!0),x(!1)},K=L=>{f(l.filter((H,ee)=>ee!==L),d),J()},Z=o&&!v&&(ce.length>0||z),re=L=>{if(L.key==="Tab"&&Z){L.preventDefault(),I(ce[Math.max(_,0)]);return}if(L.key==="Tab"&&O&&R){L.preventDefault(),k(O,R);return}if(L.key==="ArrowDown"&&Z){L.preventDefault(),b(H=>(H+1)%ce.length);return}if(L.key==="ArrowUp"&&Z){L.preventDefault(),b(H=>H<=0?ce.length-1:H-1);return}if(L.key==="Enter"){Z&&_>=0?(L.preventDefault(),I(ce[_])):W([...l.map(zi),d].filter(Boolean).join(" "));return}if(L.key==="Escape"){x(!0);return}if(L.key==="Backspace"&&!d&&l.length>0){L.preventDefault();const H=l[l.length-1];f(l.slice(0,-1),`${H.key}:${ei(ae(H))}`)}},ae=L=>L.key==="from"&&(w[L.value]??a?.[L.value])||L.value||(L.key==="admin"?"any":""),pe=()=>{P([]),Wi([])},Se=L=>L.kind==="back"?"":L.kind==="player"?"Players":L.kind==="admin"?"Source":L.kind==="role"?"Roles":L.kind==="action"?"Kinds":L.kind==="recent"?"History":"Filters";return e.jsxs("div",{className:"chat-search",children:[e.jsxs("div",{className:"chat-search-row",children:[e.jsxs("div",{className:"chat-search-field",onClick:()=>y.current?.focus(),children:[e.jsx(Ci,{className:"chat-search-icon"}),l.map((L,H)=>e.jsxs("span",{className:"chat-search-badge",children:[L.key,": ",ae(L),e.jsx(De,{className:"chat-search-badge-remove",onMouseDown:ee=>{ee.preventDefault(),K(H)}})]},L.key+L.value+H)),e.jsx("input",{ref:y,spellCheck:"false",placeholder:l.length>0?"":"Search chat...",value:d,onChange:L=>f(l,L.target.value),onKeyDown:re,onFocus:()=>{clearTimeout(p.current),u(!0),x(!1)},onBlur:()=>{p.current=setTimeout(()=>u(!1),150)}})]}),(l.length>0||d.length>0)&&e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Clear search",onClick:s,children:e.jsx(De,{})})]}),Z&&z&&e.jsxs("div",{className:"chat-search-picker",onMouseDown:L=>L.preventDefault(),children:[T&&e.jsxs("div",{className:"chat-search-option",onMouseDown:()=>I({kind:"back",id:"back"}),children:[e.jsx(pr,{className:"chat-search-option-icon"}),e.jsx("div",{className:"chat-search-option-text",children:e.jsx("span",{className:"option-title",children:"Back to filters"})})]}),e.jsx(eu,{year:le,month:de,prevMonth:Q(-1),nextMonth:Q(1),prevYear:Q(-12),nextYear:Q(12),setDate:L=>X(L),onPick:(L,H,ee)=>{const be=`${L}-${String(H+1).padStart(2,"0")}-${String(ee).padStart(2,"0")}`;k(O,be),X(null),J()}})]}),Z&&!z&&e.jsx("div",{className:"chat-search-dropdown",children:ce.map((L,H)=>e.jsxs("div",{children:[Se(L)&&(Se(L)!==Se(ce[H-1]??L)||H===0)?e.jsxs("div",{className:"chat-search-section",children:[e.jsx("span",{children:Se(L)}),L.kind==="recent"&&e.jsx(Pr,{className:"chat-search-clear",onMouseDown:ee=>{ee.preventDefault(),pe()}})]}):null,e.jsxs("div",{className:`chat-search-option ${_===H?"highlighted":""}`,onMouseEnter:()=>b(H),onMouseDown:ee=>{ee.preventDefault(),I(L)},children:[L.kind==="filter"&&e.jsx(L.Icon,{className:"chat-search-option-icon"}),L.kind==="player"&&e.jsx(yu,{className:"chat-search-option-icon"}),L.kind==="action"&&e.jsx(Ya,{className:"chat-search-option-icon"}),L.kind==="role"&&e.jsx(Er,{className:"chat-search-option-icon"}),L.kind==="admin"&&e.jsx(ou,{className:"chat-search-option-icon"}),L.kind==="recent"&&e.jsx(Ci,{className:"chat-search-option-icon"}),L.kind==="back"&&e.jsx(pr,{className:"chat-search-option-icon"}),e.jsxs("div",{className:"chat-search-option-text",children:[e.jsxs("span",{className:"option-title",children:[L.kind==="filter"&&L.title,L.kind==="player"&&L.name,L.kind==="action"&&`action: ${L.value}`,L.kind==="role"&&L.name,L.kind==="admin"&&L.value,L.kind==="recent"&&L.query,L.kind==="back"&&"Back to filters"]}),L.kind==="filter"&&e.jsx("span",{className:"option-hint",children:L.hint}),L.kind==="player"&&L.displayName!==L.name&&e.jsx("span",{className:"option-hint",children:L.displayName}),(L.kind==="action"||L.kind==="admin")&&e.jsx("span",{className:"option-hint",children:L.hint})]})]})]},L.id))})]})},Fi=5,ir=t=>{const n=new Date(t);return`${vd[n.getMonth()]} ${n.getDate()}, ${n.getFullYear()}`},Qe=(t,n=!1)=>Object.keys(t).map(Number).sort((r,s)=>n?s-r:r-s),Zh=()=>{const t=dt(te.ChatHistory),n=ie(te.ChatCalendar),[r,s]=Le("/history/:time?"),a=s?.time,[i,o]=C.useState(!0),[u,v]=C.useState(!0),[x,_]=C.useState(!1),[b,j]=C.useState({}),[P,w]=C.useState(0),m=C.useMemo(()=>new Date().getFullYear(),[]),[l,c]=C.useState(m),d=C.useMemo(()=>new Date().getMonth(),[]),[h,y]=C.useState(d),p=C.useRef(null),[g,f]=C.useState(null),[S,N]=C.useState(null),O=C.useRef(null),R=C.useRef(null),M=C.useRef([]),D=C.useRef(null),q=C.useRef(null),[T,z]=_d(),A=(T.get("q")??"").trim(),U=A.length>0&&!$h(Nu(A)),[X,V]=C.useState(T.get("q")??""),[le,de]=C.useState("newest"),[Q,he]=C.useState("newest-last"),B=C.useRef(!1);B.current=Q==="newest-first";const[oe,fe]=C.useState(null),[G,ne]=C.useState(!1),[ce,E]=C.useState(Kr()),k=Y.useUtils(),I=C.useCallback(async()=>{o(!0);const $=await k.chat.calendar.fetch();j($),o(!1)},[]),W=C.useCallback($=>{if(!$.length)return;const ue=new Set(M.current.map(ye=>ye._id));M.current=M.current.concat($.filter(ye=>!ue.has(ye._id))),M.current.sort((ye,$e)=>ye.created-$e.created);const ve=M.current[0].created,se=M.current[M.current.length-1].created;O.current=ve,R.current=se,w(ye=>ye+1)},[]),J=C.useCallback(async({before:$,after:ue},ve)=>{o(!0);const se=await k.chat.history.fetch({before:$,after:ue});W(se),v(!1),o(!1);const ye=ve;return ye&&M.current.length>200&&requestAnimationFrame(()=>{const Nt=p.current?.querySelector(".scroll-scroller")?.scrollHeight??0,Wr=B.current?ye==="top":ye==="bottom";ye==="bottom"?(M.current.splice(0,M.current.length-200),O.current=M.current[0].created,f(null)):ye==="top"&&(M.current.splice(200,M.current.length-200),R.current=M.current[M.current.length-1].created,N(null)),Wr&&(D.current=Nt),w(rr=>rr+1)}),se},[]),K=C.useMemo(()=>Object.fromEntries((oe?.senders??[]).map($=>[$.id,$.name])),[oe?.senders]),Z=C.useCallback($=>{const ue=new URLSearchParams(T);$.trim()?ue.set("q",$):ue.delete("q"),ue.toString()!==T.toString()&&z(ue,{replace:!0})},[T]);C.useEffect(()=>{const $=setTimeout(()=>Z(X),500);return()=>clearTimeout($)},[X]);const re=C.useCallback(async $=>{ne(!0);const ue=await k.chat.search.fetch({query:A,sort:le,...$===void 0?{}:{cursor:$}});fe(se=>$===void 0||!se?ue:{...ue,chats:[...se.chats,...ue.chats]});const ve=ue.chats.map(se=>({match:se,before:ue.context[se._id]?.before??[],after:ue.context[se._id]?.after??[]}));E(se=>Gh($===void 0?Kr():se,ve)),ne(!1)},[A,le]),ae=C.useRef(!0);C.useEffect(()=>{if(ae.current){ae.current=!1;return}U||ee()},[Q]),C.useEffect(()=>{if(E(Kr()),!U){fe(null);return}re()},[A,le]);const pe=async($,ue)=>{const ve=await k.chat.context.fetch({id:Number($),direction:ue,count:Fi});E(se=>Yh(se,$,ue,ve,Fi))},Se=()=>{G||!oe?.hasMore||oe.chats.length===0||re(oe.chats[oe.chats.length-1].created)},L=Q==="newest-first";C.useLayoutEffect(()=>{const $=D.current;$!==null&&(D.current=null,q.current?.keepPlaceAfterHeightChange($))},[P]);const H=L?[...M.current].reverse():M.current,ee=()=>new Promise($=>{const ue=p.current?.querySelector(".scroll-scroller");if(!ue)return $();let ve=-1,se=!1;const ye=($e,Nt)=>{const Wr=performance.now()+$e,rr=()=>{if(se)return Nt?.();if(ve>=0&&ue.scrollTop!==ve)return se=!0,Nt?.();if(ue.scrollTop=L?0:ue.scrollHeight,ve=ue.scrollTop,performance.now()>=Wr)return Nt?.();requestAnimationFrame(rr)};requestAnimationFrame(rr)};ye(600,$),document.fonts?.ready.then(()=>ye(300))});C.useEffect(()=>{const $=a&&new Date(a.match(/^\d+$/)?Number(a):a);(async()=>(u&&n&&await I(),!U&&($&&!Number.isNaN($.getTime())?(M.current=[],await J({before:$.getTime()-1}),await J({after:$.getTime()-1}),requestAnimationFrame(()=>{p.current?.querySelector(".focused")?.scrollIntoView({block:"center"})})):(M.current=[],await J({before:Date.now()}),ee()))))()},[a,U]);const be=async($,ue,ve)=>{M.current=[],w(ye=>ye+1);const se=new Date($,ue,ve).getTime();await J({after:se})},Ce=C.useRef(!1),Re=async()=>{if(!(Ce.current||O.current===null)&&!(g&&O.current<=g)){Ce.current=!0;try{(await J({before:O.current},"top")).length===0&&f(O.current)}finally{Ce.current=!1}}},Ee=async()=>{if(!(Ce.current||R.current===null)&&!(S&&R.current>=S)){Ce.current=!0;try{(await J({after:R.current},"bottom")).length===0&&N(R.current)}finally{Ce.current=!1}}},pt=C.useMemo(()=>Qe(b),[b]),mt=C.useMemo(()=>Qe(b,!0),[b]),Rt=C.useMemo(()=>{const $=mt.find(ue=>ue>l)??null;return $?[$,Qe(b[$])[0]]:null},[b,mt]),Jt=C.useMemo(()=>{const $=pt.find(ue=>ue<l)??null;return $?[$,Qe(b[$],!0)[0]]:null},[b,pt]),Zt=C.useMemo(()=>{if(h!==11&&b[l]){const ve=Qe(b[l]).find(se=>se>h);if(typeof ve=="number")return[l,ve]}const $=pt.find(ve=>ve>l);if(!$)return null;const ue=Qe(b[$])[0];return typeof ue!="number"?null:[$,ue]},[l,h,pt,b]),er=C.useMemo(()=>{if(h!==0&&b[l]){const ve=Qe(b[l],!0).find(se=>se<h);if(typeof ve=="number")return[l,ve]}const $=mt.find(ve=>ve<l);if(!$)return null;const ue=Qe(b[$],!0)[0];return typeof ue!="number"?null:[$,ue]},[l,h,b]),tr=$=>{$&&(c($[0]),y($[1]))};return t?e.jsxs(e.Fragment,{children:[e.jsxs(ze,{title:"History",children:[e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":le==="newest"?"Searching newest results first":"Searching oldest results first",onClick:()=>de($=>$==="newest"?"oldest":"newest"),children:[le==="newest"?e.jsx(uh,{}):e.jsx(dh,{})," ","Sort"]}),e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":Q==="newest-first"?"Newest messages at the top":"Newest messages at the bottom",onClick:()=>he($=>$==="newest-first"?"newest-last":"newest-first"),children:[Q==="newest-first"?e.jsx(lu,{}):e.jsx(cu,{})," Order"]}),n&&e.jsxs("div",{className:"calendar-container",children:[e.jsxs(F,{normal:!0,boxy:!0,style:{marginRight:0},"data-tooltip":"Show a calendar previewing days",onClick:()=>_(!x),children:[e.jsx(Ma,{})," Calendar"]}),e.jsx(tu,{children:x&&e.jsx(Ba.div,{initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8},transition:{duration:.15},children:e.jsx(eu,{prevYear:Jt,setDate:tr,year:l,nextYear:Rt,prevMonth:er,month:h,nextMonth:Zt,available:b,onPick:be})})})]})]}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsx("div",{className:"generic-container history-container",ref:p,children:e.jsxs("div",{className:"chat-history",children:[e.jsx(we,{attached:U&&!!oe,className:"chat-search-bar",children:e.jsx(Jh,{value:X,onChange:V,onSubmit:Z,onClear:()=>{V(""),Z("")},senderNames:K})}),U?e.jsxs(e.Fragment,{children:[oe&&e.jsxs(we,{className:"chat-search-summary",children:[e.jsxs("span",{children:[oe.total,oe.totalCapped?"+":""," result",oe.total===1?"":"s"]}),oe.senders.map($=>e.jsxs("span",{className:"chat-search-chip",children:["from: ",$.name]},$.id)),oe.filters.filter($=>$.key!=="from").map($=>e.jsxs("span",{className:"chat-search-chip",children:[$.key,":"," ",$.value||($.key==="admin"?"any":"")]},$.key+$.value))]}),e.jsx("div",{className:"scroll-container",children:e.jsxs(gi,{loading:G,onBottom:Se,onTop:()=>{},onTopScrollsToBottom:!1,offset:500,className:"scroll-scroller",children:[Kh(ce,L).map(($,ue,ve)=>{if($.kind==="gap")return e.jsx("div",{className:"chat-search-expand","data-tooltip":$.direction==="before"?"Show earlier messages":"Show later messages",onClick:()=>pe($.id,$.direction),children:le==="newest"?$.direction==="before"?e.jsx(Ea,{}):e.jsx(Ri,{}):$.direction==="before"?e.jsx(Ri,{}):e.jsx(Ea,{})},`gap:${$.direction}:${$.id}`);const se=ir($.entry.created),ye=ve.slice(0,ue).reverse().find($e=>$e.kind==="entry");return e.jsxs(pi.Fragment,{children:[(!ye||se!==ir(ye.entry.created))&&e.jsx("div",{className:"chat-new-day",children:se}),e.jsx(vi,{log:$.entry,dim:!$.isMatch})]},$.id)}),oe&&oe.chats.length===0&&!G&&e.jsx("div",{className:"chat-search-empty",children:"No messages match this search"})]})}),e.jsx(xe,{active:G&&!oe,size:"huge",children:"Searching"})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scroll-container",children:e.jsx(gi,{ref:q,loading:i,onTop:L?Ee:Re,onBottom:L?Re:Ee,onTopScrollsToBottom:!1,offset:500,className:"scroll-scroller",children:H.map(($,ue,ve)=>{const se=ir($.created),ye=ve[ue-1];return e.jsxs(pi.Fragment,{children:[(!ye||se!==ir(ye.created))&&e.jsx("div",{className:"chat-new-day",children:se}),e.jsx(vi,{log:$})]},$._id)})})}),e.jsx(xe,{active:i&&u,size:"huge",children:"Loading Chat"})]})]})})]})]}):null};var Xr={exports:{}},Et={},Wt={exports:{}},ef=Wt.exports,Bi;function ti(){return Bi||(Bi=1,(function(t,n){(function(r,s){s(n)})(ef,(function(r){function s(G){return function(ce,E,k,I,W,J,K){return G(ce,E,K)}}function a(G){return function(ce,E,k,I){if(!ce||!E||typeof ce!="object"||typeof E!="object")return G(ce,E,k,I);var W=I.get(ce),J=I.get(E);if(W&&J)return W===E&&J===ce;I.set(ce,E),I.set(E,ce);var K=G(ce,E,k,I);return I.delete(ce),I.delete(E),K}}function i(G,ne){var ce={};for(var E in G)ce[E]=G[E];for(var E in ne)ce[E]=ne[E];return ce}function o(G){return G.constructor===Object||G.constructor==null}function u(G){return typeof G.then=="function"}function v(G,ne){return G===ne||G!==G&&ne!==ne}var x="[object Arguments]",_="[object Boolean]",b="[object Date]",j="[object RegExp]",P="[object Map]",w="[object Number]",m="[object Object]",l="[object Set]",c="[object String]",d=Object.prototype.toString;function h(G){var ne=G.areArraysEqual,ce=G.areDatesEqual,E=G.areMapsEqual,k=G.areObjectsEqual,I=G.areRegExpsEqual,W=G.areSetsEqual,J=G.createIsNestedEqual,K=J(Z);function Z(re,ae,pe){if(re===ae)return!0;if(!re||!ae||typeof re!="object"||typeof ae!="object")return re!==re&&ae!==ae;if(o(re)&&o(ae))return k(re,ae,K,pe);var Se=Array.isArray(re),L=Array.isArray(ae);if(Se||L)return Se===L&&ne(re,ae,K,pe);var H=d.call(re);return H!==d.call(ae)?!1:H===b?ce(re,ae,K,pe):H===j?I(re,ae,K,pe):H===P?E(re,ae,K,pe):H===l?W(re,ae,K,pe):H===m||H===x?u(re)||u(ae)?!1:k(re,ae,K,pe):H===_||H===w||H===c?v(re.valueOf(),ae.valueOf()):!1}return Z}function y(G,ne,ce,E){var k=G.length;if(ne.length!==k)return!1;for(;k-- >0;)if(!ce(G[k],ne[k],k,k,G,ne,E))return!1;return!0}var p=a(y);function g(G,ne){return v(G.valueOf(),ne.valueOf())}function f(G,ne,ce,E){var k=G.size===ne.size;if(!k)return!1;if(!G.size)return!0;var I={},W=0;return G.forEach(function(J,K){if(k){var Z=!1,re=0;ne.forEach(function(ae,pe){!Z&&!I[re]&&(Z=ce(K,pe,W,re,G,ne,E)&&ce(J,ae,K,pe,G,ne,E))&&(I[re]=!0),re++}),W++,k=Z}}),k}var S=a(f),N="_owner",O=Object.prototype.hasOwnProperty;function R(G,ne,ce,E){var k=Object.keys(G),I=k.length;if(Object.keys(ne).length!==I)return!1;for(var W;I-- >0;){if(W=k[I],W===N){var J=!!G.$$typeof,K=!!ne.$$typeof;if((J||K)&&J!==K)return!1}if(!O.call(ne,W)||!ce(G[W],ne[W],W,W,G,ne,E))return!1}return!0}var M=a(R);function D(G,ne){return G.source===ne.source&&G.flags===ne.flags}function q(G,ne,ce,E){var k=G.size===ne.size;if(!k)return!1;if(!G.size)return!0;var I={};return G.forEach(function(W,J){if(k){var K=!1,Z=0;ne.forEach(function(re,ae){!K&&!I[Z]&&(K=ce(W,re,J,ae,G,ne,E))&&(I[Z]=!0),Z++}),k=K}}),k}var T=a(q),z=Object.freeze({areArraysEqual:y,areDatesEqual:g,areMapsEqual:f,areObjectsEqual:R,areRegExpsEqual:D,areSetsEqual:q,createIsNestedEqual:s}),A=Object.freeze({areArraysEqual:p,areDatesEqual:g,areMapsEqual:S,areObjectsEqual:M,areRegExpsEqual:D,areSetsEqual:T,createIsNestedEqual:s}),U=h(z);function X(G,ne){return U(G,ne,void 0)}var V=h(i(z,{createIsNestedEqual:function(){return v}}));function le(G,ne){return V(G,ne,void 0)}var de=h(A);function Q(G,ne){return de(G,ne,new WeakMap)}var he=h(i(A,{createIsNestedEqual:function(){return v}}));function B(G,ne){return he(G,ne,new WeakMap)}function oe(G){return h(i(z,G(z)))}function fe(G){var ne=h(i(A,G(A)));return(function(ce,E,k){return k===void 0&&(k=new WeakMap),ne(ce,E,k)})}r.circularDeepEqual=Q,r.circularShallowEqual=B,r.createCustomCircularEqual=fe,r.createCustomEqual=oe,r.deepEqual=X,r.sameValueZeroEqual=v,r.shallowEqual=le,Object.defineProperty(r,"__esModule",{value:!0})}))})(Wt,Wt.exports)),Wt.exports}var or={exports:{}},Ui;function Mr(){if(Ui)return or.exports;Ui=1;function t(r){var s,a,i="";if(typeof r=="string"||typeof r=="number")i+=r;else if(typeof r=="object")if(Array.isArray(r)){var o=r.length;for(s=0;s<o;s++)r[s]&&(a=t(r[s]))&&(i&&(i+=" "),i+=a)}else for(a in r)r[a]&&(i&&(i+=" "),i+=a);return i}function n(){for(var r,s,a=0,i="",o=arguments.length;a<o;a++)(r=arguments[a])&&(s=t(r))&&(i&&(i+=" "),i+=s);return i}return or.exports=n,or.exports.clsx=n,or.exports}var ge={},Vr,$i;function tf(){return $i||($i=1,Vr=function(n,r,s){return n===r?!0:n.className===r.className&&s(n.style,r.style)&&n.width===r.width&&n.autoSize===r.autoSize&&n.cols===r.cols&&n.draggableCancel===r.draggableCancel&&n.draggableHandle===r.draggableHandle&&s(n.verticalCompact,r.verticalCompact)&&s(n.compactType,r.compactType)&&s(n.layout,r.layout)&&s(n.margin,r.margin)&&s(n.containerPadding,r.containerPadding)&&n.rowHeight===r.rowHeight&&n.maxRows===r.maxRows&&n.isBounded===r.isBounded&&n.isDraggable===r.isDraggable&&n.isResizable===r.isResizable&&n.allowOverlap===r.allowOverlap&&n.preventCollision===r.preventCollision&&n.useCSSTransforms===r.useCSSTransforms&&n.transformScale===r.transformScale&&n.isDroppable===r.isDroppable&&s(n.resizeHandles,r.resizeHandles)&&s(n.resizeHandle,r.resizeHandle)&&n.onLayoutChange===r.onLayoutChange&&n.onDragStart===r.onDragStart&&n.onDrag===r.onDrag&&n.onDragStop===r.onDragStop&&n.onResizeStart===r.onResizeStart&&n.onResize===r.onResize&&n.onResizeStop===r.onResizeStop&&n.onDrop===r.onDrop&&s(n.droppingItem,r.droppingItem)&&s(n.innerRef,r.innerRef)}),Vr}var Gi;function Ct(){if(Gi)return ge;Gi=1,Object.defineProperty(ge,"__esModule",{value:!0}),ge.bottom=s,ge.childrenEqual=v,ge.cloneLayout=a,ge.cloneLayoutItem=u,ge.collides=_,ge.compact=b,ge.compactItem=w,ge.compactType=G,ge.correctBounds=m,ge.fastPositionEqual=x,ge.fastRGLPropsEqual=void 0,ge.getAllCollisions=d,ge.getFirstCollision=c,ge.getLayoutItem=l,ge.getStatics=h,ge.modifyLayout=i,ge.moveElement=y,ge.moveElementAwayFromCollision=p,ge.noop=void 0,ge.perc=g,ge.resizeItemInDirection=V,ge.setTopLeft=de,ge.setTransform=le,ge.sortLayoutItems=Q,ge.sortLayoutItemsByColRow=B,ge.sortLayoutItemsByRowCol=he,ge.synchronizeLayoutWithChildren=oe,ge.validateLayout=fe,ge.withLayoutItem=o;var t=ti(),n=r(Fe());function r(E){return E&&E.__esModule?E:{default:E}}function s(E){let k=0,I;for(let W=0,J=E.length;W<J;W++)I=E[W].y+E[W].h,I>k&&(k=I);return k}function a(E){const k=Array(E.length);for(let I=0,W=E.length;I<W;I++)k[I]=u(E[I]);return k}function i(E,k){const I=Array(E.length);for(let W=0,J=E.length;W<J;W++)k.i===E[W].i?I[W]=k:I[W]=E[W];return I}function o(E,k,I){let W=l(E,k);return W?(W=I(u(W)),E=i(E,W),[E,W]):[E,null]}function u(E){return{w:E.w,h:E.h,x:E.x,y:E.y,i:E.i,minW:E.minW,maxW:E.maxW,minH:E.minH,maxH:E.maxH,moved:!!E.moved,static:!!E.static,isDraggable:E.isDraggable,isResizable:E.isResizable,resizeHandles:E.resizeHandles,isBounded:E.isBounded}}function v(E,k){return(0,t.deepEqual)(n.default.Children.map(E,I=>I?.key),n.default.Children.map(k,I=>I?.key))&&(0,t.deepEqual)(n.default.Children.map(E,I=>I?.props["data-grid"]),n.default.Children.map(k,I=>I?.props["data-grid"]))}ge.fastRGLPropsEqual=tf();function x(E,k){return E.left===k.left&&E.top===k.top&&E.width===k.width&&E.height===k.height}function _(E,k){return!(E.i===k.i||E.x+E.w<=k.x||E.x>=k.x+k.w||E.y+E.h<=k.y||E.y>=k.y+k.h)}function b(E,k,I,W){const J=h(E),K=Q(E,k),Z=Array(E.length);for(let re=0,ae=K.length;re<ae;re++){let pe=u(K[re]);pe.static||(pe=w(J,pe,k,I,K,W),J.push(pe)),Z[E.indexOf(K[re])]=pe,pe.moved=!1}return Z}const j={x:"w",y:"h"};function P(E,k,I,W){const J=j[W];k[W]+=1;const K=E.map(Z=>Z.i).indexOf(k.i);for(let Z=K+1;Z<E.length;Z++){const re=E[Z];if(!re.static){if(re.y>k.y+k.h)break;_(k,re)&&P(E,re,I+k[J],W)}}k[W]=I}function w(E,k,I,W,J,K){const Z=I==="vertical",re=I==="horizontal";if(Z)for(k.y=Math.min(s(E),k.y);k.y>0&&!c(E,k);)k.y--;else if(re)for(;k.x>0&&!c(E,k);)k.x--;let ae;for(;(ae=c(E,k))&&!(I===null&&K);)if(re?P(J,k,ae.x+ae.w,"x"):P(J,k,ae.y+ae.h,"y"),re&&k.x+k.w>W)for(k.x=W-k.w,k.y++;k.x>0&&!c(E,k);)k.x--;return k.y=Math.max(k.y,0),k.x=Math.max(k.x,0),k}function m(E,k){const I=h(E);for(let W=0,J=E.length;W<J;W++){const K=E[W];if(K.x+K.w>k.cols&&(K.x=k.cols-K.w),K.x<0&&(K.x=0,K.w=k.cols),!K.static)I.push(K);else for(;c(I,K);)K.y++}return E}function l(E,k){for(let I=0,W=E.length;I<W;I++)if(E[I].i===k)return E[I]}function c(E,k){for(let I=0,W=E.length;I<W;I++)if(_(E[I],k))return E[I]}function d(E,k){return E.filter(I=>_(I,k))}function h(E){return E.filter(k=>k.static)}function y(E,k,I,W,J,K,Z,re,ae){if(k.static&&k.isDraggable!==!0||k.y===W&&k.x===I)return E;`${k.i}${String(I)}${String(W)}${k.x}${k.y}`;const pe=k.x,Se=k.y;typeof I=="number"&&(k.x=I),typeof W=="number"&&(k.y=W),k.moved=!0;let L=Q(E,Z);(Z==="vertical"&&typeof W=="number"?Se>=W:Z==="horizontal"&&typeof I=="number"&&pe>=I)&&(L=L.reverse());const ee=d(L,k),be=ee.length>0;if(be&&ae)return a(E);if(be&&K)return`${k.i}`,k.x=pe,k.y=Se,k.moved=!1,E;for(let Ce=0,Re=ee.length;Ce<Re;Ce++){const Ee=ee[Ce];`${k.i}${k.x}${k.y}${Ee.i}${Ee.x}${Ee.y}`,!Ee.moved&&(Ee.static?E=p(E,Ee,k,J,Z):E=p(E,k,Ee,J,Z))}return E}function p(E,k,I,W,J,K){const Z=J==="horizontal",re=J==="vertical",ae=k.static;if(W){W=!1;const L={x:Z?Math.max(k.x-I.w,0):I.x,y:re?Math.max(k.y-I.h,0):I.y,w:I.w,h:I.h,i:"-1"},H=c(E,L),ee=H&&H.y+H.h>k.y,be=H&&k.x+k.w>H.x;if(H){if(ee&&re)return y(E,I,void 0,k.y+1,W,ae,J);if(ee&&J==null)return k.y=I.y,I.y=I.y+I.h,E;if(be&&Z)return y(E,k,I.x,void 0,W,ae,J)}else return`${I.i}${L.x}${L.y}`,y(E,I,Z?L.x:void 0,re?L.y:void 0,W,ae,J)}const pe=Z?I.x+1:void 0,Se=re?I.y+1:void 0;return pe==null&&Se==null?E:y(E,I,Z?I.x+1:void 0,re?I.y+1:void 0,W,ae,J)}function g(E){return E*100+"%"}const f=(E,k,I,W)=>E+I>W?k:I,S=(E,k,I)=>E<0?k:I,N=E=>Math.max(0,E),O=E=>Math.max(0,E),R=(E,k,I)=>{let{left:W,height:J,width:K}=k;const Z=E.top-(J-E.height);return{left:W,width:K,height:S(Z,E.height,J),top:O(Z)}},M=(E,k,I)=>{let{top:W,left:J,height:K,width:Z}=k;return{top:W,height:K,width:f(E.left,E.width,Z,I),left:N(J)}},D=(E,k,I)=>{let{top:W,height:J,width:K}=k;const Z=E.left-(K-E.width);return{height:J,width:Z<0?E.width:f(E.left,E.width,K,I),top:O(W),left:N(Z)}},q=(E,k,I)=>{let{top:W,left:J,height:K,width:Z}=k;return{width:Z,left:J,height:S(W,E.height,K),top:O(W)}},X={n:R,ne:function(){return R(arguments.length<=0?void 0:arguments[0],M(...arguments))},e:M,se:function(){return q(arguments.length<=0?void 0:arguments[0],M(...arguments))},s:q,sw:function(){return q(arguments.length<=0?void 0:arguments[0],D(...arguments))},w:D,nw:function(){return R(arguments.length<=0?void 0:arguments[0],D(...arguments))}};function V(E,k,I,W){const J=X[E];return J?J(k,{...k,...I},W):I}function le(E){let{top:k,left:I,width:W,height:J}=E;const K=`translate(${I}px,${k}px)`;return{transform:K,WebkitTransform:K,MozTransform:K,msTransform:K,OTransform:K,width:`${W}px`,height:`${J}px`,position:"absolute"}}function de(E){let{top:k,left:I,width:W,height:J}=E;return{top:`${k}px`,left:`${I}px`,width:`${W}px`,height:`${J}px`,position:"absolute"}}function Q(E,k){return k==="horizontal"?B(E):k==="vertical"?he(E):E}function he(E){return E.slice(0).sort(function(k,I){return k.y>I.y||k.y===I.y&&k.x>I.x?1:k.y===I.y&&k.x===I.x?0:-1})}function B(E){return E.slice(0).sort(function(k,I){return k.x>I.x||k.x===I.x&&k.y>I.y?1:-1})}function oe(E,k,I,W,J){E=E||[];const K=[];n.default.Children.forEach(k,re=>{if(re?.key==null)return;const ae=l(E,String(re.key)),pe=re.props["data-grid"];ae&&pe==null?K.push(u(ae)):pe?K.push(u({...pe,i:re.key})):K.push(u({w:1,h:1,x:0,y:s(K),i:String(re.key)}))});const Z=m(K,{cols:I});return J?Z:b(Z,W,I)}function fe(E){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Layout";const I=["x","y","w","h"];if(!Array.isArray(E))throw new Error(k+" must be an array!");for(let W=0,J=E.length;W<J;W++){const K=E[W];for(let Z=0;Z<I.length;Z++){const re=I[Z],ae=K[re];if(typeof ae!="number"||Number.isNaN(ae))throw new Error(`ReactGridLayout: ${k}[${W}].${re} must be a number! Received: ${ae} (${typeof ae})`)}if(typeof K.i<"u"&&typeof K.i!="string")throw new Error(`ReactGridLayout: ${k}[${W}].i must be a string! Received: ${K.i} (${typeof K.i})`)}}function G(E){const{verticalCompact:k,compactType:I}=E||{};return k===!1?null:I}function ne(){}const ce=()=>{};return ge.noop=ce,ge}var Ge={},Yi;function ri(){if(Yi)return Ge;Yi=1,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.calcGridColWidth=t,Ge.calcGridItemPosition=r,Ge.calcGridItemWHPx=n,Ge.calcWH=a,Ge.calcXY=s,Ge.clamp=i;function t(o){const{margin:u,containerPadding:v,containerWidth:x,cols:_}=o;return(x-u[0]*(_-1)-v[0]*2)/_}function n(o,u,v){return Number.isFinite(o)?Math.round(u*o+Math.max(0,o-1)*v):o}function r(o,u,v,x,_,b){const{margin:j,containerPadding:P,rowHeight:w}=o,m=t(o),l={};return b&&b.resizing?(l.width=Math.round(b.resizing.width),l.height=Math.round(b.resizing.height)):(l.width=n(x,m,j[0]),l.height=n(_,w,j[1])),b&&b.dragging?(l.top=Math.round(b.dragging.top),l.left=Math.round(b.dragging.left)):b&&b.resizing&&typeof b.resizing.top=="number"&&typeof b.resizing.left=="number"?(l.top=Math.round(b.resizing.top),l.left=Math.round(b.resizing.left)):(l.top=Math.round((w+j[1])*v+P[1]),l.left=Math.round((m+j[0])*u+P[0])),l}function s(o,u,v,x,_){const{margin:b,containerPadding:j,cols:P,rowHeight:w,maxRows:m}=o,l=t(o);let c=Math.round((v-j[0])/(l+b[0])),d=Math.round((u-j[1])/(w+b[1]));return c=i(c,0,P-x),d=i(d,0,m-_),{x:c,y:d}}function a(o,u,v,x,_,b){const{margin:j,maxRows:P,cols:w,rowHeight:m}=o,l=t(o);let c=Math.round((u+j[0])/(l+j[0])),d=Math.round((v+j[1])/(m+j[1])),h=i(c,0,w-x),y=i(d,0,P-_);return["sw","w","nw"].indexOf(b)!==-1&&(h=i(c,0,w)),["nw","n","ne"].indexOf(b)!==-1&&(y=i(d,0,P)),{w:h,h:y}}function i(o,u,v){return Math.max(Math.min(o,v),u)}return Ge}var kt={},Qr={exports:{}},Jr,Ki;function rf(){if(Ki)return Jr;Ki=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Jr=t,Jr}var Zr,Xi;function nf(){if(Xi)return Zr;Xi=1;var t=rf();function n(){}function r(){}return r.resetWarningCache=n,Zr=function(){function s(o,u,v,x,_,b){if(b!==t){var j=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw j.name="Invariant Violation",j}}s.isRequired=s;function a(){return s}var i={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:a,element:s,elementType:s,instanceOf:a,node:s,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:r,resetWarningCache:n};return i.PropTypes=i,i},Zr}var Vi;function it(){return Vi||(Vi=1,Qr.exports=nf()()),Qr.exports}var Mt={exports:{}},en={},je={},Je={},Qi;function Or(){if(Qi)return Je;Qi=1,Object.defineProperty(Je,"__esModule",{value:!0}),Je.dontSetMe=a,Je.findInArray=t,Je.int=s,Je.isFunction=n,Je.isNum=r;function t(i,o){for(let u=0,v=i.length;u<v;u++)if(o.apply(o,[i[u],u,i]))return i[u]}function n(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Function]"}function r(i){return typeof i=="number"&&!isNaN(i)}function s(i){return parseInt(i,10)}function a(i,o,u){if(i[o])return new Error(`Invalid prop ${o} passed to ${u} - do not set this, set it on the child.`)}return Je}var Ze={},Ji;function sf(){if(Ji)return Ze;Ji=1,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.browserPrefixToKey=r,Ze.browserPrefixToStyle=s,Ze.default=void 0,Ze.getPrefix=n;const t=["Moz","Webkit","O","ms"];function n(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"transform";if(typeof window>"u")return"";const o=window.document?.documentElement?.style;if(!o||i in o)return"";for(let u=0;u<t.length;u++)if(r(i,t[u])in o)return t[u];return""}function r(i,o){return o?`${o}${a(i)}`:i}function s(i,o){return o?`-${o.toLowerCase()}-${i}`:i}function a(i){let o="",u=!0;for(let v=0;v<i.length;v++)u?(o+=i[v].toUpperCase(),u=!1):i[v]==="-"?u=!0:o+=i[v];return o}return Ze.default=n(),Ze}var Zi;function ni(){if(Zi)return je;Zi=1,Object.defineProperty(je,"__esModule",{value:!0}),je.addClassName=p,je.addEvent=o,je.addUserSelectStyles=d,je.createCSSTransform=P,je.createSVGTransform=w,je.getTouch=l,je.getTouchIdentifier=c,je.getTranslation=m,je.innerHeight=_,je.innerWidth=b,je.matchesSelector=a,je.matchesSelectorAndParentsTo=i,je.offsetXYFromParent=j,je.outerHeight=v,je.outerWidth=x,je.removeClassName=g,je.removeEvent=u,je.scheduleRemoveUserSelectStyles=h;var t=Or(),n=r(sf());function r(f,S){if(typeof WeakMap=="function")var N=new WeakMap,O=new WeakMap;return(r=function(R,M){if(!M&&R&&R.__esModule)return R;var D,q,T={__proto__:null,default:R};if(R===null||typeof R!="object"&&typeof R!="function")return T;if(D=M?O:N){if(D.has(R))return D.get(R);D.set(R,T)}for(const z in R)z!=="default"&&{}.hasOwnProperty.call(R,z)&&((q=(D=Object.defineProperty)&&Object.getOwnPropertyDescriptor(R,z))&&(q.get||q.set)?D(T,z,q):T[z]=R[z]);return T})(f,S)}let s="";function a(f,S){return s||(s=(0,t.findInArray)(["matches","webkitMatchesSelector","mozMatchesSelector","msMatchesSelector","oMatchesSelector"],function(N){return(0,t.isFunction)(f[N])})),(0,t.isFunction)(f[s])?f[s](S):!1}function i(f,S,N){let O=f;do{if(a(O,S))return!0;if(O===N)return!1;O=O.parentNode}while(O);return!1}function o(f,S,N,O){if(!f)return;const R={capture:!0,...O};f.addEventListener?f.addEventListener(S,N,R):f.attachEvent?f.attachEvent("on"+S,N):f["on"+S]=N}function u(f,S,N,O){if(!f)return;const R={capture:!0,...O};f.removeEventListener?f.removeEventListener(S,N,R):f.detachEvent?f.detachEvent("on"+S,N):f["on"+S]=null}function v(f){let S=f.clientHeight;const N=f.ownerDocument.defaultView.getComputedStyle(f);return S+=(0,t.int)(N.borderTopWidth),S+=(0,t.int)(N.borderBottomWidth),S}function x(f){let S=f.clientWidth;const N=f.ownerDocument.defaultView.getComputedStyle(f);return S+=(0,t.int)(N.borderLeftWidth),S+=(0,t.int)(N.borderRightWidth),S}function _(f){let S=f.clientHeight;const N=f.ownerDocument.defaultView.getComputedStyle(f);return S-=(0,t.int)(N.paddingTop),S-=(0,t.int)(N.paddingBottom),S}function b(f){let S=f.clientWidth;const N=f.ownerDocument.defaultView.getComputedStyle(f);return S-=(0,t.int)(N.paddingLeft),S-=(0,t.int)(N.paddingRight),S}function j(f,S,N){const R=S===S.ownerDocument.body?{left:0,top:0}:S.getBoundingClientRect(),M=(f.clientX+S.scrollLeft-R.left)/N,D=(f.clientY+S.scrollTop-R.top)/N;return{x:M,y:D}}function P(f,S){const N=m(f,S,"px");return{[(0,n.browserPrefixToKey)("transform",n.default)]:N}}function w(f,S){return m(f,S,"")}function m(f,S,N){let{x:O,y:R}=f,M=`translate(${O}${N},${R}${N})`;if(S){const D=`${typeof S.x=="string"?S.x:S.x+N}`,q=`${typeof S.y=="string"?S.y:S.y+N}`;M=`translate(${D}, ${q})`+M}return M}function l(f,S){return f.targetTouches&&(0,t.findInArray)(f.targetTouches,N=>S===N.identifier)||f.changedTouches&&(0,t.findInArray)(f.changedTouches,N=>S===N.identifier)}function c(f){if(f.targetTouches&&f.targetTouches[0])return f.targetTouches[0].identifier;if(f.changedTouches&&f.changedTouches[0])return f.changedTouches[0].identifier}function d(f){if(!f)return;let S=f.getElementById("react-draggable-style-el");S||(S=f.createElement("style"),S.type="text/css",S.id="react-draggable-style-el",S.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
3
+ `,S.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
4
+ `,f.getElementsByTagName("head")[0].appendChild(S)),f.body&&p(f.body,"react-draggable-transparent-selection")}function h(f){window.requestAnimationFrame?window.requestAnimationFrame(()=>{y(f)}):y(f)}function y(f){if(f)try{if(f.body&&g(f.body,"react-draggable-transparent-selection"),f.selection)f.selection.empty();else{const S=(f.defaultView||window).getSelection();S&&S.type!=="Caret"&&S.removeAllRanges()}}catch{}}function p(f,S){f.classList?f.classList.add(S):f.className.match(new RegExp(`(?:^|\\s)${S}(?!\\S)`))||(f.className+=` ${S}`)}function g(f,S){f.classList?f.classList.remove(S):f.className=f.className.replace(new RegExp(`(?:^|\\s)${S}(?!\\S)`,"g"),"")}return je}var Be={},eo;function ku(){if(eo)return Be;eo=1,Object.defineProperty(Be,"__esModule",{value:!0}),Be.canDragX=a,Be.canDragY=i,Be.createCoreData=u,Be.createDraggableData=v,Be.getBoundPosition=r,Be.getControlPosition=o,Be.snapToGrid=s;var t=Or(),n=ni();function r(b,j,P){if(!b.props.bounds)return[j,P];let{bounds:w}=b.props;w=typeof w=="string"?w:x(w);const m=_(b);if(typeof w=="string"){const{ownerDocument:l}=m,c=l.defaultView;let d;if(w==="parent"?d=m.parentNode:d=m.getRootNode().querySelector(w),!(d instanceof c.HTMLElement))throw new Error('Bounds selector "'+w+'" could not find an element.');const h=d,y=c.getComputedStyle(m),p=c.getComputedStyle(h);w={left:-m.offsetLeft+(0,t.int)(p.paddingLeft)+(0,t.int)(y.marginLeft),top:-m.offsetTop+(0,t.int)(p.paddingTop)+(0,t.int)(y.marginTop),right:(0,n.innerWidth)(h)-(0,n.outerWidth)(m)-m.offsetLeft+(0,t.int)(p.paddingRight)-(0,t.int)(y.marginRight),bottom:(0,n.innerHeight)(h)-(0,n.outerHeight)(m)-m.offsetTop+(0,t.int)(p.paddingBottom)-(0,t.int)(y.marginBottom)}}return(0,t.isNum)(w.right)&&(j=Math.min(j,w.right)),(0,t.isNum)(w.bottom)&&(P=Math.min(P,w.bottom)),(0,t.isNum)(w.left)&&(j=Math.max(j,w.left)),(0,t.isNum)(w.top)&&(P=Math.max(P,w.top)),[j,P]}function s(b,j,P){const w=Math.round(j/b[0])*b[0],m=Math.round(P/b[1])*b[1];return[w,m]}function a(b){return b.props.axis==="both"||b.props.axis==="x"}function i(b){return b.props.axis==="both"||b.props.axis==="y"}function o(b,j,P){const w=typeof j=="number"?(0,n.getTouch)(b,j):null;if(typeof j=="number"&&!w)return null;const m=_(P),l=P.props.offsetParent||m.offsetParent||m.ownerDocument.body;return(0,n.offsetXYFromParent)(w||b,l,P.props.scale)}function u(b,j,P){const w=!(0,t.isNum)(b.lastX),m=_(b);return w?{node:m,deltaX:0,deltaY:0,lastX:j,lastY:P,x:j,y:P}:{node:m,deltaX:j-b.lastX,deltaY:P-b.lastY,lastX:b.lastX,lastY:b.lastY,x:j,y:P}}function v(b,j){const P=b.props.scale;return{node:j.node,x:b.state.x+j.deltaX/P,y:b.state.y+j.deltaY/P,deltaX:j.deltaX/P,deltaY:j.deltaY/P,lastX:b.state.x,lastY:b.state.y}}function x(b){return{left:b.left,top:b.top,right:b.right,bottom:b.bottom}}function _(b){const j=b.findDOMNode();if(!j)throw new Error("<DraggableCore>: Unmounted during event!");return j}return Be}var Ot={},lr={},to;function Mu(){if(to)return lr;to=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.default=t;function t(){}return lr}var ro;function af(){if(ro)return Ot;ro=1,Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.default=void 0;var t=v(Fe()),n=u(it()),r=u(Va()),s=ni(),a=ku(),i=Or(),o=u(Mu());function u(m){return m&&m.__esModule?m:{default:m}}function v(m,l){if(typeof WeakMap=="function")var c=new WeakMap,d=new WeakMap;return(v=function(h,y){if(!y&&h&&h.__esModule)return h;var p,g,f={__proto__:null,default:h};if(h===null||typeof h!="object"&&typeof h!="function")return f;if(p=y?d:c){if(p.has(h))return p.get(h);p.set(h,f)}for(const S in h)S!=="default"&&{}.hasOwnProperty.call(h,S)&&((g=(p=Object.defineProperty)&&Object.getOwnPropertyDescriptor(h,S))&&(g.get||g.set)?p(f,S,g):f[S]=h[S]);return f})(m,l)}function x(m,l,c){return(l=_(l))in m?Object.defineProperty(m,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):m[l]=c,m}function _(m){var l=b(m,"string");return typeof l=="symbol"?l:l+""}function b(m,l){if(typeof m!="object"||!m)return m;var c=m[Symbol.toPrimitive];if(c!==void 0){var d=c.call(m,l);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(m)}const j={touch:{start:"touchstart",move:"touchmove",stop:"touchend"},mouse:{start:"mousedown",move:"mousemove",stop:"mouseup"}};let P=j.mouse,w=class extends t.Component{constructor(){super(...arguments),x(this,"dragging",!1),x(this,"lastX",NaN),x(this,"lastY",NaN),x(this,"touchIdentifier",null),x(this,"mounted",!1),x(this,"handleDragStart",l=>{if(this.props.onMouseDown(l),!this.props.allowAnyClick&&typeof l.button=="number"&&l.button!==0)return!1;const c=this.findDOMNode();if(!c||!c.ownerDocument||!c.ownerDocument.body)throw new Error("<DraggableCore> not mounted on DragStart!");const{ownerDocument:d}=c;if(this.props.disabled||!(l.target instanceof d.defaultView.Node)||this.props.handle&&!(0,s.matchesSelectorAndParentsTo)(l.target,this.props.handle,c)||this.props.cancel&&(0,s.matchesSelectorAndParentsTo)(l.target,this.props.cancel,c))return;l.type==="touchstart"&&!this.props.allowMobileScroll&&l.preventDefault();const h=(0,s.getTouchIdentifier)(l);this.touchIdentifier=h;const y=(0,a.getControlPosition)(l,h,this);if(y==null)return;const{x:p,y:g}=y,f=(0,a.createCoreData)(this,p,g);(0,o.default)("DraggableCore: handleDragStart: %j",f),(0,o.default)("calling",this.props.onStart),!(this.props.onStart(l,f)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,s.addUserSelectStyles)(d),this.dragging=!0,this.lastX=p,this.lastY=g,(0,s.addEvent)(d,P.move,this.handleDrag),(0,s.addEvent)(d,P.stop,this.handleDragStop))}),x(this,"handleDrag",l=>{const c=(0,a.getControlPosition)(l,this.touchIdentifier,this);if(c==null)return;let{x:d,y:h}=c;if(Array.isArray(this.props.grid)){let g=d-this.lastX,f=h-this.lastY;if([g,f]=(0,a.snapToGrid)(this.props.grid,g,f),!g&&!f)return;d=this.lastX+g,h=this.lastY+f}const y=(0,a.createCoreData)(this,d,h);if((0,o.default)("DraggableCore: handleDrag: %j",y),this.props.onDrag(l,y)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent("mouseup"))}catch{const f=document.createEvent("MouseEvents");f.initMouseEvent("mouseup",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(f)}return}this.lastX=d,this.lastY=h}),x(this,"handleDragStop",l=>{if(!this.dragging)return;const c=(0,a.getControlPosition)(l,this.touchIdentifier,this);if(c==null)return;let{x:d,y:h}=c;if(Array.isArray(this.props.grid)){let f=d-this.lastX||0,S=h-this.lastY||0;[f,S]=(0,a.snapToGrid)(this.props.grid,f,S),d=this.lastX+f,h=this.lastY+S}const y=(0,a.createCoreData)(this,d,h);if(this.props.onStop(l,y)===!1||this.mounted===!1)return!1;const g=this.findDOMNode();g&&this.props.enableUserSelectHack&&(0,s.scheduleRemoveUserSelectStyles)(g.ownerDocument),(0,o.default)("DraggableCore: handleDragStop: %j",y),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,g&&((0,o.default)("DraggableCore: Removing handlers"),(0,s.removeEvent)(g.ownerDocument,P.move,this.handleDrag),(0,s.removeEvent)(g.ownerDocument,P.stop,this.handleDragStop))}),x(this,"onMouseDown",l=>(P=j.mouse,this.handleDragStart(l))),x(this,"onMouseUp",l=>(P=j.mouse,this.handleDragStop(l))),x(this,"onTouchStart",l=>(P=j.touch,this.handleDragStart(l))),x(this,"onTouchEnd",l=>(P=j.touch,this.handleDragStop(l)))}componentDidMount(){this.mounted=!0;const l=this.findDOMNode();l&&(0,s.addEvent)(l,j.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;const l=this.findDOMNode();if(l){const{ownerDocument:c}=l;(0,s.removeEvent)(c,j.mouse.move,this.handleDrag),(0,s.removeEvent)(c,j.touch.move,this.handleDrag),(0,s.removeEvent)(c,j.mouse.stop,this.handleDragStop),(0,s.removeEvent)(c,j.touch.stop,this.handleDragStop),(0,s.removeEvent)(l,j.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,s.scheduleRemoveUserSelectStyles)(c)}}findDOMNode(){return this.props?.nodeRef?this.props?.nodeRef?.current:r.default.findDOMNode(this)}render(){return t.cloneElement(t.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};return Ot.default=w,x(w,"displayName","DraggableCore"),x(w,"propTypes",{allowAnyClick:n.default.bool,allowMobileScroll:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(m,l){if(m[l]&&m[l].nodeType!==1)throw new Error("Draggable's offsetParent must be a DOM Node.")},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:i.dontSetMe,style:i.dontSetMe,transform:i.dontSetMe}),x(w,"defaultProps",{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1}),Ot}var no;function of(){return no||(no=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),Object.defineProperty(t,"DraggableCore",{enumerable:!0,get:function(){return v.default}}),t.default=void 0;var n=b(Fe()),r=_(it()),s=_(Va()),a=Mr(),i=ni(),o=ku(),u=Or(),v=_(af()),x=_(Mu());function _(c){return c&&c.__esModule?c:{default:c}}function b(c,d){if(typeof WeakMap=="function")var h=new WeakMap,y=new WeakMap;return(b=function(p,g){if(!g&&p&&p.__esModule)return p;var f,S,N={__proto__:null,default:p};if(p===null||typeof p!="object"&&typeof p!="function")return N;if(f=g?y:h){if(f.has(p))return f.get(p);f.set(p,N)}for(const O in p)O!=="default"&&{}.hasOwnProperty.call(p,O)&&((S=(f=Object.defineProperty)&&Object.getOwnPropertyDescriptor(p,O))&&(S.get||S.set)?f(N,O,S):N[O]=p[O]);return N})(c,d)}function j(){return j=Object.assign?Object.assign.bind():function(c){for(var d=1;d<arguments.length;d++){var h=arguments[d];for(var y in h)({}).hasOwnProperty.call(h,y)&&(c[y]=h[y])}return c},j.apply(null,arguments)}function P(c,d,h){return(d=w(d))in c?Object.defineProperty(c,d,{value:h,enumerable:!0,configurable:!0,writable:!0}):c[d]=h,c}function w(c){var d=m(c,"string");return typeof d=="symbol"?d:d+""}function m(c,d){if(typeof c!="object"||!c)return c;var h=c[Symbol.toPrimitive];if(h!==void 0){var y=h.call(c,d);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(c)}class l extends n.Component{static getDerivedStateFromProps(d,h){let{position:y}=d,{prevPropsPosition:p}=h;return y&&(!p||y.x!==p.x||y.y!==p.y)?((0,x.default)("Draggable: getDerivedStateFromProps %j",{position:y,prevPropsPosition:p}),{x:y.x,y:y.y,prevPropsPosition:{...y}}):null}constructor(d){super(d),P(this,"onDragStart",(h,y)=>{if((0,x.default)("Draggable: onDragStart: %j",y),this.props.onStart(h,(0,o.createDraggableData)(this,y))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),P(this,"onDrag",(h,y)=>{if(!this.state.dragging)return!1;(0,x.default)("Draggable: onDrag: %j",y);const p=(0,o.createDraggableData)(this,y),g={x:p.x,y:p.y,slackX:0,slackY:0};if(this.props.bounds){const{x:S,y:N}=g;g.x+=this.state.slackX,g.y+=this.state.slackY;const[O,R]=(0,o.getBoundPosition)(this,g.x,g.y);g.x=O,g.y=R,g.slackX=this.state.slackX+(S-g.x),g.slackY=this.state.slackY+(N-g.y),p.x=g.x,p.y=g.y,p.deltaX=g.x-this.state.x,p.deltaY=g.y-this.state.y}if(this.props.onDrag(h,p)===!1)return!1;this.setState(g)}),P(this,"onDragStop",(h,y)=>{if(!this.state.dragging||this.props.onStop(h,(0,o.createDraggableData)(this,y))===!1)return!1;(0,x.default)("Draggable: onDragStop: %j",y);const g={dragging:!1,slackX:0,slackY:0};if(!!this.props.position){const{x:S,y:N}=this.props.position;g.x=S,g.y=N}this.setState(g)}),this.state={dragging:!1,dragged:!1,x:d.position?d.position.x:d.defaultPosition.x,y:d.position?d.position.y:d.defaultPosition.y,prevPropsPosition:{...d.position},slackX:0,slackY:0,isElementSVG:!1},d.position&&!(d.onDrag||d.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}componentDidMount(){typeof window.SVGElement<"u"&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){return this.props?.nodeRef?.current??s.default.findDOMNode(this)}render(){const{axis:d,bounds:h,children:y,defaultPosition:p,defaultClassName:g,defaultClassNameDragging:f,defaultClassNameDragged:S,position:N,positionOffset:O,scale:R,...M}=this.props;let D={},q=null;const z=!!!N||this.state.dragging,A=N||p,U={x:(0,o.canDragX)(this)&&z?this.state.x:A.x,y:(0,o.canDragY)(this)&&z?this.state.y:A.y};this.state.isElementSVG?q=(0,i.createSVGTransform)(U,O):D=(0,i.createCSSTransform)(U,O);const X=(0,a.clsx)(y.props.className||"",g,{[f]:this.state.dragging,[S]:this.state.dragged});return n.createElement(v.default,j({},M,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),n.cloneElement(n.Children.only(y),{className:X,style:{...y.props.style,...D},transform:q}))}}t.default=l,P(l,"displayName","Draggable"),P(l,"propTypes",{...v.default.propTypes,axis:r.default.oneOf(["both","x","y","none"]),bounds:r.default.oneOfType([r.default.shape({left:r.default.number,right:r.default.number,top:r.default.number,bottom:r.default.number}),r.default.string,r.default.oneOf([!1])]),defaultClassName:r.default.string,defaultClassNameDragging:r.default.string,defaultClassNameDragged:r.default.string,defaultPosition:r.default.shape({x:r.default.number,y:r.default.number}),positionOffset:r.default.shape({x:r.default.oneOfType([r.default.number,r.default.string]),y:r.default.oneOfType([r.default.number,r.default.string])}),position:r.default.shape({x:r.default.number,y:r.default.number}),className:u.dontSetMe,style:u.dontSetMe,transform:u.dontSetMe}),P(l,"defaultProps",{...v.default.defaultProps,axis:"both",bounds:!1,defaultClassName:"react-draggable",defaultClassNameDragging:"react-draggable-dragging",defaultClassNameDragged:"react-draggable-dragged",defaultPosition:{x:0,y:0},scale:1})})(en)),en}var so;function si(){if(so)return Mt.exports;so=1;const{default:t,DraggableCore:n}=of();return Mt.exports=t,Mt.exports.default=t,Mt.exports.DraggableCore=n,Mt.exports}var Dt={exports:{}},At={},cr={},ao;function lf(){if(ao)return cr;ao=1,cr.__esModule=!0,cr.cloneElement=u;var t=n(Fe());function n(v){return v&&v.__esModule?v:{default:v}}function r(v,x){var _=Object.keys(v);if(Object.getOwnPropertySymbols){var b=Object.getOwnPropertySymbols(v);x&&(b=b.filter(function(j){return Object.getOwnPropertyDescriptor(v,j).enumerable})),_.push.apply(_,b)}return _}function s(v){for(var x=1;x<arguments.length;x++){var _=arguments[x]!=null?arguments[x]:{};x%2?r(Object(_),!0).forEach(function(b){a(v,b,_[b])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(_)):r(Object(_)).forEach(function(b){Object.defineProperty(v,b,Object.getOwnPropertyDescriptor(_,b))})}return v}function a(v,x,_){return x=i(x),x in v?Object.defineProperty(v,x,{value:_,enumerable:!0,configurable:!0,writable:!0}):v[x]=_,v}function i(v){var x=o(v,"string");return typeof x=="symbol"?x:String(x)}function o(v,x){if(typeof v!="object"||v===null)return v;var _=v[Symbol.toPrimitive];if(_!==void 0){var b=_.call(v,x);if(typeof b!="object")return b;throw new TypeError("@@toPrimitive must return a primitive value.")}return(x==="string"?String:Number)(v)}function u(v,x){return x.style&&v.props.style&&(x.style=s(s({},v.props.style),x.style)),x.className&&v.props.className&&(x.className=v.props.className+" "+x.className),t.default.cloneElement(v,x)}return cr}var qt={},io;function Ou(){if(io)return qt;io=1,qt.__esModule=!0,qt.resizableProps=void 0;var t=n(it());si();function n(s){return s&&s.__esModule?s:{default:s}}var r={axis:t.default.oneOf(["both","x","y","none"]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:t.default.node,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){for(var a=arguments.length,i=new Array(a),o=0;o<a;o++)i[o]=arguments[o];var u=i[0];if(u.axis==="both"||u.axis==="y"){var v;return(v=t.default.number).isRequired.apply(v,i)}return t.default.number.apply(t.default,i)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),transformScale:t.default.number,width:function(){for(var a=arguments.length,i=new Array(a),o=0;o<a;o++)i[o]=arguments[o];var u=i[0];if(u.axis==="both"||u.axis==="x"){var v;return(v=t.default.number).isRequired.apply(v,i)}return t.default.number.apply(t.default,i)}};return qt.resizableProps=r,qt}var oo;function Du(){if(oo)return At;oo=1,At.__esModule=!0,At.default=void 0;var t=o(Fe()),n=si(),r=lf(),s=Ou(),a=["children","className","draggableOpts","width","height","handle","handleSize","lockAspectRatio","axis","minConstraints","maxConstraints","onResize","onResizeStop","onResizeStart","resizeHandles","transformScale"];function i(c){if(typeof WeakMap!="function")return null;var d=new WeakMap,h=new WeakMap;return(i=function(p){return p?h:d})(c)}function o(c,d){if(c&&c.__esModule)return c;if(c===null||typeof c!="object"&&typeof c!="function")return{default:c};var h=i(d);if(h&&h.has(c))return h.get(c);var y={},p=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var g in c)if(g!=="default"&&Object.prototype.hasOwnProperty.call(c,g)){var f=p?Object.getOwnPropertyDescriptor(c,g):null;f&&(f.get||f.set)?Object.defineProperty(y,g,f):y[g]=c[g]}return y.default=c,h&&h.set(c,y),y}function u(){return u=Object.assign?Object.assign.bind():function(c){for(var d=1;d<arguments.length;d++){var h=arguments[d];for(var y in h)Object.prototype.hasOwnProperty.call(h,y)&&(c[y]=h[y])}return c},u.apply(this,arguments)}function v(c,d){if(c==null)return{};var h={},y=Object.keys(c),p,g;for(g=0;g<y.length;g++)p=y[g],!(d.indexOf(p)>=0)&&(h[p]=c[p]);return h}function x(c,d){var h=Object.keys(c);if(Object.getOwnPropertySymbols){var y=Object.getOwnPropertySymbols(c);d&&(y=y.filter(function(p){return Object.getOwnPropertyDescriptor(c,p).enumerable})),h.push.apply(h,y)}return h}function _(c){for(var d=1;d<arguments.length;d++){var h=arguments[d]!=null?arguments[d]:{};d%2?x(Object(h),!0).forEach(function(y){b(c,y,h[y])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(h)):x(Object(h)).forEach(function(y){Object.defineProperty(c,y,Object.getOwnPropertyDescriptor(h,y))})}return c}function b(c,d,h){return d=j(d),d in c?Object.defineProperty(c,d,{value:h,enumerable:!0,configurable:!0,writable:!0}):c[d]=h,c}function j(c){var d=P(c,"string");return typeof d=="symbol"?d:String(d)}function P(c,d){if(typeof c!="object"||c===null)return c;var h=c[Symbol.toPrimitive];if(h!==void 0){var y=h.call(c,d);if(typeof y!="object")return y;throw new TypeError("@@toPrimitive must return a primitive value.")}return(d==="string"?String:Number)(c)}function w(c,d){c.prototype=Object.create(d.prototype),c.prototype.constructor=c,m(c,d)}function m(c,d){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(y,p){return y.__proto__=p,y},m(c,d)}var l=(function(c){w(d,c);function d(){for(var y,p=arguments.length,g=new Array(p),f=0;f<p;f++)g[f]=arguments[f];return y=c.call.apply(c,[this].concat(g))||this,y.handleRefs={},y.lastHandleRect=null,y.slack=null,y}var h=d.prototype;return h.componentWillUnmount=function(){this.resetData()},h.resetData=function(){this.lastHandleRect=this.slack=null},h.runConstraints=function(p,g){var f=this.props,S=f.minConstraints,N=f.maxConstraints,O=f.lockAspectRatio;if(!S&&!N&&!O)return[p,g];if(O){var R=this.props.width/this.props.height,M=p-this.props.width,D=g-this.props.height;Math.abs(M)>Math.abs(D*R)?g=p/R:p=g*R}var q=p,T=g,z=this.slack||[0,0],A=z[0],U=z[1];return p+=A,g+=U,S&&(p=Math.max(S[0],p),g=Math.max(S[1],g)),N&&(p=Math.min(N[0],p),g=Math.min(N[1],g)),this.slack=[A+(q-p),U+(T-g)],[p,g]},h.resizeHandler=function(p,g){var f=this;return function(S,N){var O=N.node,R=N.deltaX,M=N.deltaY;p==="onResizeStart"&&f.resetData();var D=(f.props.axis==="both"||f.props.axis==="x")&&g!=="n"&&g!=="s",q=(f.props.axis==="both"||f.props.axis==="y")&&g!=="e"&&g!=="w";if(!(!D&&!q)){var T=g[0],z=g[g.length-1],A=O.getBoundingClientRect();if(f.lastHandleRect!=null){if(z==="w"){var U=A.left-f.lastHandleRect.left;R+=U}if(T==="n"){var X=A.top-f.lastHandleRect.top;M+=X}}f.lastHandleRect=A,z==="w"&&(R=-R),T==="n"&&(M=-M);var V=f.props.width+(D?R/f.props.transformScale:0),le=f.props.height+(q?M/f.props.transformScale:0),de=f.runConstraints(V,le);V=de[0],le=de[1];var Q=V!==f.props.width||le!==f.props.height,he=typeof f.props[p]=="function"?f.props[p]:null,B=p==="onResize"&&!Q;he&&!B&&(S.persist==null||S.persist(),he(S,{node:O,size:{width:V,height:le},handle:g})),p==="onResizeStop"&&f.resetData()}}},h.renderResizeHandle=function(p,g){var f=this.props.handle;if(!f)return t.createElement("span",{className:"react-resizable-handle react-resizable-handle-"+p,ref:g});if(typeof f=="function")return f(p,g);var S=typeof f.type=="string",N=_({ref:g},S?{}:{handleAxis:p});return t.cloneElement(f,N)},h.render=function(){var p=this,g=this.props,f=g.children,S=g.className,N=g.draggableOpts;g.width,g.height,g.handle,g.handleSize,g.lockAspectRatio,g.axis,g.minConstraints,g.maxConstraints,g.onResize,g.onResizeStop,g.onResizeStart;var O=g.resizeHandles;g.transformScale;var R=v(g,a);return(0,r.cloneElement)(f,_(_({},R),{},{className:(S?S+" ":"")+"react-resizable",children:[].concat(f.props.children,O.map(function(M){var D,q=(D=p.handleRefs[M])!=null?D:p.handleRefs[M]=t.createRef();return t.createElement(n.DraggableCore,u({},N,{nodeRef:q,key:"resizableHandle-"+M,onStop:p.resizeHandler("onResizeStop",M),onStart:p.resizeHandler("onResizeStart",M),onDrag:p.resizeHandler("onResize",M)}),p.renderResizeHandle(M,q))}))}))},d})(t.Component);return At.default=l,l.propTypes=s.resizableProps,l.defaultProps={axis:"both",handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:["se"],transformScale:1},At}var Tt={},lo;function cf(){if(lo)return Tt;lo=1,Tt.__esModule=!0,Tt.default=void 0;var t=u(Fe()),n=i(it()),r=i(Du()),s=Ou(),a=["handle","handleSize","onResize","onResizeStart","onResizeStop","draggableOpts","minConstraints","maxConstraints","lockAspectRatio","axis","width","height","resizeHandles","style","transformScale"];function i(d){return d&&d.__esModule?d:{default:d}}function o(d){if(typeof WeakMap!="function")return null;var h=new WeakMap,y=new WeakMap;return(o=function(g){return g?y:h})(d)}function u(d,h){if(d&&d.__esModule)return d;if(d===null||typeof d!="object"&&typeof d!="function")return{default:d};var y=o(h);if(y&&y.has(d))return y.get(d);var p={},g=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var f in d)if(f!=="default"&&Object.prototype.hasOwnProperty.call(d,f)){var S=g?Object.getOwnPropertyDescriptor(d,f):null;S&&(S.get||S.set)?Object.defineProperty(p,f,S):p[f]=d[f]}return p.default=d,y&&y.set(d,p),p}function v(){return v=Object.assign?Object.assign.bind():function(d){for(var h=1;h<arguments.length;h++){var y=arguments[h];for(var p in y)Object.prototype.hasOwnProperty.call(y,p)&&(d[p]=y[p])}return d},v.apply(this,arguments)}function x(d,h){var y=Object.keys(d);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(d);h&&(p=p.filter(function(g){return Object.getOwnPropertyDescriptor(d,g).enumerable})),y.push.apply(y,p)}return y}function _(d){for(var h=1;h<arguments.length;h++){var y=arguments[h]!=null?arguments[h]:{};h%2?x(Object(y),!0).forEach(function(p){b(d,p,y[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(d,Object.getOwnPropertyDescriptors(y)):x(Object(y)).forEach(function(p){Object.defineProperty(d,p,Object.getOwnPropertyDescriptor(y,p))})}return d}function b(d,h,y){return h=j(h),h in d?Object.defineProperty(d,h,{value:y,enumerable:!0,configurable:!0,writable:!0}):d[h]=y,d}function j(d){var h=P(d,"string");return typeof h=="symbol"?h:String(h)}function P(d,h){if(typeof d!="object"||d===null)return d;var y=d[Symbol.toPrimitive];if(y!==void 0){var p=y.call(d,h);if(typeof p!="object")return p;throw new TypeError("@@toPrimitive must return a primitive value.")}return(h==="string"?String:Number)(d)}function w(d,h){if(d==null)return{};var y={},p=Object.keys(d),g,f;for(f=0;f<p.length;f++)g=p[f],!(h.indexOf(g)>=0)&&(y[g]=d[g]);return y}function m(d,h){d.prototype=Object.create(h.prototype),d.prototype.constructor=d,l(d,h)}function l(d,h){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(p,g){return p.__proto__=g,p},l(d,h)}var c=(function(d){m(h,d);function h(){for(var p,g=arguments.length,f=new Array(g),S=0;S<g;S++)f[S]=arguments[S];return p=d.call.apply(d,[this].concat(f))||this,p.state={width:p.props.width,height:p.props.height,propsWidth:p.props.width,propsHeight:p.props.height},p.onResize=function(N,O){var R=O.size;p.props.onResize?(N.persist==null||N.persist(),p.setState(R,function(){return p.props.onResize&&p.props.onResize(N,O)})):p.setState(R)},p}h.getDerivedStateFromProps=function(g,f){return f.propsWidth!==g.width||f.propsHeight!==g.height?{width:g.width,height:g.height,propsWidth:g.width,propsHeight:g.height}:null};var y=h.prototype;return y.render=function(){var g=this.props,f=g.handle,S=g.handleSize;g.onResize;var N=g.onResizeStart,O=g.onResizeStop,R=g.draggableOpts,M=g.minConstraints,D=g.maxConstraints,q=g.lockAspectRatio,T=g.axis;g.width,g.height;var z=g.resizeHandles,A=g.style,U=g.transformScale,X=w(g,a);return t.createElement(r.default,{axis:T,draggableOpts:R,handle:f,handleSize:S,height:this.state.height,lockAspectRatio:q,maxConstraints:D,minConstraints:M,onResizeStart:N,onResize:this.onResize,onResizeStop:O,resizeHandles:z,transformScale:U,width:this.state.width},t.createElement("div",v({},X,{style:_(_({},A),{},{width:this.state.width+"px",height:this.state.height+"px"})})))},h})(t.Component);return Tt.default=c,c.propTypes=_(_({},s.resizableProps),{},{children:n.default.element}),Tt}var co;function uf(){return co||(co=1,Dt.exports=function(){throw new Error("Don't instantiate Resizable directly! Use require('react-resizable').Resizable")},Dt.exports.Resizable=Du().default,Dt.exports.ResizableBox=cf().default),Dt.exports}var Ye={},uo;function Au(){if(uo)return Ye;uo=1,Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.resizeHandleType=Ye.resizeHandleAxesType=Ye.default=void 0;var t=r(it()),n=r(Fe());function r(i){return i&&i.__esModule?i:{default:i}}const s=Ye.resizeHandleAxesType=t.default.arrayOf(t.default.oneOf(["s","w","e","n","sw","nw","se","ne"])),a=Ye.resizeHandleType=t.default.oneOfType([t.default.node,t.default.func]);return Ye.default={className:t.default.string,style:t.default.object,width:t.default.number,autoSize:t.default.bool,cols:t.default.number,draggableCancel:t.default.string,draggableHandle:t.default.string,verticalCompact:function(i){i.verticalCompact},compactType:t.default.oneOf(["vertical","horizontal"]),layout:function(i){var o=i.layout;o!==void 0&&Ct().validateLayout(o,"layout")},margin:t.default.arrayOf(t.default.number),containerPadding:t.default.arrayOf(t.default.number),rowHeight:t.default.number,maxRows:t.default.number,isBounded:t.default.bool,isDraggable:t.default.bool,isResizable:t.default.bool,allowOverlap:t.default.bool,preventCollision:t.default.bool,useCSSTransforms:t.default.bool,transformScale:t.default.number,isDroppable:t.default.bool,resizeHandles:s,resizeHandle:a,onLayoutChange:t.default.func,onDragStart:t.default.func,onDrag:t.default.func,onDragStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,onResizeStop:t.default.func,onDrop:t.default.func,droppingItem:t.default.shape({i:t.default.string.isRequired,w:t.default.number.isRequired,h:t.default.number.isRequired}),children:function(i,o){const u=i[o],v={};n.default.Children.forEach(u,function(x){if(x?.key!=null){if(v[x.key])throw new Error('Duplicate child key "'+x.key+'" found! This will cause problems in ReactGridLayout.');v[x.key]=!0}})},innerRef:t.default.any},Ye}var ho;function df(){if(ho)return kt;ho=1,Object.defineProperty(kt,"__esModule",{value:!0}),kt.default=void 0;var t=x(Fe()),n=Va(),r=x(it()),s=si(),a=uf(),i=Ct(),o=ri(),u=Au(),v=x(Mr());function x(w){return w&&w.__esModule?w:{default:w}}function _(w,m,l){return(m=b(m))in w?Object.defineProperty(w,m,{value:l,enumerable:!0,configurable:!0,writable:!0}):w[m]=l,w}function b(w){var m=j(w,"string");return typeof m=="symbol"?m:m+""}function j(w,m){if(typeof w!="object"||!w)return w;var l=w[Symbol.toPrimitive];if(l!==void 0){var c=l.call(w,m);if(typeof c!="object")return c;throw new TypeError("@@toPrimitive must return a primitive value.")}return(m==="string"?String:Number)(w)}let P=class extends t.default.Component{constructor(){super(...arguments),_(this,"state",{resizing:null,dragging:null,className:""}),_(this,"elementRef",t.default.createRef()),_(this,"onDragStart",(m,l)=>{let{node:c}=l;const{onDragStart:d,transformScale:h}=this.props;if(!d)return;const y={top:0,left:0},{offsetParent:p}=c;if(!p)return;const g=p.getBoundingClientRect(),f=c.getBoundingClientRect(),S=f.left/h,N=g.left/h,O=f.top/h,R=g.top/h;y.left=S-N+p.scrollLeft,y.top=O-R+p.scrollTop,this.setState({dragging:y});const{x:M,y:D}=(0,o.calcXY)(this.getPositionParams(),y.top,y.left,this.props.w,this.props.h);return d.call(this,this.props.i,M,D,{e:m,node:c,newPosition:y})}),_(this,"onDrag",(m,l,c)=>{let{node:d,deltaX:h,deltaY:y}=l;const{onDrag:p}=this.props;if(!p)return;if(!this.state.dragging)throw new Error("onDrag called before onDragStart.");let g=this.state.dragging.top+y,f=this.state.dragging.left+h;const{isBounded:S,i:N,w:O,h:R,containerWidth:M}=this.props,D=this.getPositionParams();if(S){const{offsetParent:A}=d;if(A){const{margin:U,rowHeight:X}=this.props,V=A.clientHeight-(0,o.calcGridItemWHPx)(R,X,U[1]);g=(0,o.clamp)(g,0,V);const le=(0,o.calcGridColWidth)(D),de=M-(0,o.calcGridItemWHPx)(O,le,U[0]);f=(0,o.clamp)(f,0,de)}}const q={top:g,left:f};c?this.setState({dragging:q}):(0,n.flushSync)(()=>{this.setState({dragging:q})});const{x:T,y:z}=(0,o.calcXY)(D,g,f,O,R);return p.call(this,N,T,z,{e:m,node:d,newPosition:q})}),_(this,"onDragStop",(m,l)=>{let{node:c}=l;const{onDragStop:d}=this.props;if(!d)return;if(!this.state.dragging)throw new Error("onDragEnd called before onDragStart.");const{w:h,h:y,i:p}=this.props,{left:g,top:f}=this.state.dragging,S={top:f,left:g};this.setState({dragging:null});const{x:N,y:O}=(0,o.calcXY)(this.getPositionParams(),f,g,h,y);return d.call(this,p,N,O,{e:m,node:c,newPosition:S})}),_(this,"onResizeStop",(m,l,c)=>this.onResizeHandler(m,l,c,"onResizeStop")),_(this,"onResizeStart",(m,l,c)=>this.onResizeHandler(m,l,c,"onResizeStart")),_(this,"onResize",(m,l,c)=>this.onResizeHandler(m,l,c,"onResize"))}shouldComponentUpdate(m,l){if(this.props.children!==m.children||this.props.droppingPosition!==m.droppingPosition)return!0;const c=(0,o.calcGridItemPosition)(this.getPositionParams(this.props),this.props.x,this.props.y,this.props.w,this.props.h,this.state),d=(0,o.calcGridItemPosition)(this.getPositionParams(m),m.x,m.y,m.w,m.h,l);return!(0,i.fastPositionEqual)(c,d)||this.props.useCSSTransforms!==m.useCSSTransforms}componentDidMount(){this.moveDroppingItem({})}componentDidUpdate(m){this.moveDroppingItem(m)}moveDroppingItem(m){const{droppingPosition:l}=this.props;if(!l)return;const c=this.elementRef.current;if(!c)return;const d=m.droppingPosition||{left:0,top:0},{dragging:h}=this.state,y=h&&l.left!==d.left||l.top!==d.top;if(!h)this.onDragStart(l.e,{node:c,deltaX:l.left,deltaY:l.top});else if(y){const p=l.left-h.left,g=l.top-h.top;this.onDrag(l.e,{node:c,deltaX:p,deltaY:g},!0)}}getPositionParams(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.props;return{cols:m.cols,containerPadding:m.containerPadding,containerWidth:m.containerWidth,margin:m.margin,maxRows:m.maxRows,rowHeight:m.rowHeight}}createStyle(m){const{usePercentages:l,containerWidth:c,useCSSTransforms:d}=this.props;let h;return d?h=(0,i.setTransform)(m):(h=(0,i.setTopLeft)(m),l&&(h.left=(0,i.perc)(m.left/c),h.width=(0,i.perc)(m.width/c))),h}mixinDraggable(m,l){return t.default.createElement(s.DraggableCore,{disabled:!l,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop,handle:this.props.handle,cancel:".react-resizable-handle"+(this.props.cancel?","+this.props.cancel:""),scale:this.props.transformScale,nodeRef:this.elementRef},m)}curryResizeHandler(m,l){return(c,d)=>l(c,d,m)}mixinResizable(m,l,c){const{cols:d,minW:h,minH:y,maxW:p,maxH:g,transformScale:f,resizeHandles:S,resizeHandle:N}=this.props,O=this.getPositionParams(),R=(0,o.calcGridItemPosition)(O,0,0,d,0).width,M=(0,o.calcGridItemPosition)(O,0,0,h,y),D=(0,o.calcGridItemPosition)(O,0,0,p,g),q=[M.width,M.height],T=[Math.min(D.width,R),Math.min(D.height,1/0)];return t.default.createElement(a.Resizable,{draggableOpts:{disabled:!c},className:c?void 0:"react-resizable-hide",width:l.width,height:l.height,minConstraints:q,maxConstraints:T,onResizeStop:this.curryResizeHandler(l,this.onResizeStop),onResizeStart:this.curryResizeHandler(l,this.onResizeStart),onResize:this.curryResizeHandler(l,this.onResize),transformScale:f,resizeHandles:S,handle:N},m)}onResizeHandler(m,l,c,d){let{node:h,size:y,handle:p}=l;const g=this.props[d];if(!g)return;const{x:f,y:S,i:N,maxH:O,minH:R,containerWidth:M}=this.props,{minW:D,maxW:q}=this.props;let T=y;h&&(T=(0,i.resizeItemInDirection)(p,c,y,M),(0,n.flushSync)(()=>{this.setState({resizing:d==="onResizeStop"?null:T})}));let{w:z,h:A}=(0,o.calcWH)(this.getPositionParams(),T.width,T.height,f,S,p);z=(0,o.clamp)(z,Math.max(D,1),q),A=(0,o.clamp)(A,R,O),g.call(this,N,z,A,{e:m,node:h,size:T,handle:p})}render(){const{x:m,y:l,w:c,h:d,isDraggable:h,isResizable:y,droppingPosition:p,useCSSTransforms:g}=this.props,f=(0,o.calcGridItemPosition)(this.getPositionParams(),m,l,c,d,this.state),S=t.default.Children.only(this.props.children);let N=t.default.cloneElement(S,{ref:this.elementRef,className:(0,v.default)("react-grid-item",S.props.className,this.props.className,{static:this.props.static,resizing:!!this.state.resizing,"react-draggable":h,"react-draggable-dragging":!!this.state.dragging,dropping:!!p,cssTransforms:g}),style:{...this.props.style,...S.props.style,...this.createStyle(f)}});return N=this.mixinResizable(N,f,y),N=this.mixinDraggable(N,h),N}};return kt.default=P,_(P,"propTypes",{children:r.default.element,cols:r.default.number.isRequired,containerWidth:r.default.number.isRequired,rowHeight:r.default.number.isRequired,margin:r.default.array.isRequired,maxRows:r.default.number.isRequired,containerPadding:r.default.array.isRequired,x:r.default.number.isRequired,y:r.default.number.isRequired,w:r.default.number.isRequired,h:r.default.number.isRequired,minW:function(w,m){const l=w[m];if(typeof l!="number")return new Error("minWidth not Number");if(l>w.w||l>w.maxW)return new Error("minWidth larger than item width/maxWidth")},maxW:function(w,m){const l=w[m];if(typeof l!="number")return new Error("maxWidth not Number");if(l<w.w||l<w.minW)return new Error("maxWidth smaller than item width/minWidth")},minH:function(w,m){const l=w[m];if(typeof l!="number")return new Error("minHeight not Number");if(l>w.h||l>w.maxH)return new Error("minHeight larger than item height/maxHeight")},maxH:function(w,m){const l=w[m];if(typeof l!="number")return new Error("maxHeight not Number");if(l<w.h||l<w.minH)return new Error("maxHeight smaller than item height/minHeight")},i:r.default.string.isRequired,resizeHandles:u.resizeHandleAxesType,resizeHandle:u.resizeHandleType,onDragStop:r.default.func,onDragStart:r.default.func,onDrag:r.default.func,onResizeStop:r.default.func,onResizeStart:r.default.func,onResize:r.default.func,isDraggable:r.default.bool.isRequired,isResizable:r.default.bool.isRequired,isBounded:r.default.bool.isRequired,static:r.default.bool,useCSSTransforms:r.default.bool.isRequired,transformScale:r.default.number,className:r.default.string,handle:r.default.string,cancel:r.default.string,droppingPosition:r.default.shape({e:r.default.object.isRequired,left:r.default.number.isRequired,top:r.default.number.isRequired})}),_(P,"defaultProps",{className:"",cancel:"",handle:"",minH:1,minW:1,maxH:1/0,maxW:1/0,transformScale:1}),kt}var fo;function qu(){if(fo)return Et;fo=1,Object.defineProperty(Et,"__esModule",{value:!0}),Et.default=void 0;var t=v(Fe()),n=ti(),r=u(Mr()),s=Ct(),a=ri(),i=u(df()),o=u(Au());function u(m){return m&&m.__esModule?m:{default:m}}function v(m,l){if(typeof WeakMap=="function")var c=new WeakMap,d=new WeakMap;return(v=function(h,y){if(!y&&h&&h.__esModule)return h;var p,g,f={__proto__:null,default:h};if(h===null||typeof h!="object"&&typeof h!="function")return f;if(p=y?d:c){if(p.has(h))return p.get(h);p.set(h,f)}for(const S in h)S!=="default"&&{}.hasOwnProperty.call(h,S)&&((g=(p=Object.defineProperty)&&Object.getOwnPropertyDescriptor(h,S))&&(g.get||g.set)?p(f,S,g):f[S]=h[S]);return f})(m,l)}function x(m,l,c){return(l=_(l))in m?Object.defineProperty(m,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):m[l]=c,m}function _(m){var l=b(m,"string");return typeof l=="symbol"?l:l+""}function b(m,l){if(typeof m!="object"||!m)return m;var c=m[Symbol.toPrimitive];if(c!==void 0){var d=c.call(m,l);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(m)}const j="react-grid-layout";let P=!1;try{P=/firefox/i.test(navigator.userAgent)}catch{}let w=class extends t.Component{constructor(){super(...arguments),x(this,"state",{activeDrag:null,layout:(0,s.synchronizeLayoutWithChildren)(this.props.layout,this.props.children,this.props.cols,(0,s.compactType)(this.props),this.props.allowOverlap),mounted:!1,oldDragItem:null,oldLayout:null,oldResizeItem:null,resizing:!1,droppingDOMNode:null,children:[]}),x(this,"dragEnterCounter",0),x(this,"onDragStart",(l,c,d,h)=>{let{e:y,node:p}=h;const{layout:g}=this.state,f=(0,s.getLayoutItem)(g,l);if(!f)return;const S={w:f.w,h:f.h,x:f.x,y:f.y,placeholder:!0,i:l};return this.setState({oldDragItem:(0,s.cloneLayoutItem)(f),oldLayout:g,activeDrag:S}),this.props.onDragStart(g,f,f,null,y,p)}),x(this,"onDrag",(l,c,d,h)=>{let{e:y,node:p}=h;const{oldDragItem:g}=this.state;let{layout:f}=this.state;const{cols:S,allowOverlap:N,preventCollision:O}=this.props,R=(0,s.getLayoutItem)(f,l);if(!R)return;const M={w:R.w,h:R.h,x:R.x,y:R.y,placeholder:!0,i:l};f=(0,s.moveElement)(f,R,c,d,!0,O,(0,s.compactType)(this.props),S,N),this.props.onDrag(f,g,R,M,y,p),this.setState({layout:N?f:(0,s.compact)(f,(0,s.compactType)(this.props),S),activeDrag:M})}),x(this,"onDragStop",(l,c,d,h)=>{let{e:y,node:p}=h;if(!this.state.activeDrag)return;const{oldDragItem:g}=this.state;let{layout:f}=this.state;const{cols:S,preventCollision:N,allowOverlap:O}=this.props,R=(0,s.getLayoutItem)(f,l);if(!R)return;f=(0,s.moveElement)(f,R,c,d,!0,N,(0,s.compactType)(this.props),S,O);const D=O?f:(0,s.compact)(f,(0,s.compactType)(this.props),S);this.props.onDragStop(D,g,R,null,y,p);const{oldLayout:q}=this.state;this.setState({activeDrag:null,layout:D,oldDragItem:null,oldLayout:null}),this.onLayoutMaybeChanged(D,q)}),x(this,"onResizeStart",(l,c,d,h)=>{let{e:y,node:p}=h;const{layout:g}=this.state,f=(0,s.getLayoutItem)(g,l);f&&(this.setState({oldResizeItem:(0,s.cloneLayoutItem)(f),oldLayout:this.state.layout,resizing:!0}),this.props.onResizeStart(g,f,f,null,y,p))}),x(this,"onResize",(l,c,d,h)=>{let{e:y,node:p,size:g,handle:f}=h;const{oldResizeItem:S}=this.state,{layout:N}=this.state,{cols:O,preventCollision:R,allowOverlap:M}=this.props;let D=!1,q,T,z;const[A,U]=(0,s.withLayoutItem)(N,l,V=>{let le;return T=V.x,z=V.y,["sw","w","nw","n","ne"].indexOf(f)!==-1&&(["sw","nw","w"].indexOf(f)!==-1&&(T=V.x+(V.w-c),c=V.x!==T&&T<0?V.w:c,T=T<0?0:T),["ne","n","nw"].indexOf(f)!==-1&&(z=V.y+(V.h-d),d=V.y!==z&&z<0?V.h:d,z=z<0?0:z),D=!0),R&&!M&&(le=(0,s.getAllCollisions)(N,{...V,w:c,h:d,x:T,y:z}).filter(Q=>Q.i!==V.i).length>0,le&&(z=V.y,d=V.h,T=V.x,c=V.w,D=!1)),V.w=c,V.h=d,V});if(!U)return;q=A,D&&(q=(0,s.moveElement)(A,U,T,z,!0,this.props.preventCollision,(0,s.compactType)(this.props),O,M));const X={w:U.w,h:U.h,x:U.x,y:U.y,static:!0,i:l};this.props.onResize(q,S,U,X,y,p),this.setState({layout:M?q:(0,s.compact)(q,(0,s.compactType)(this.props),O),activeDrag:X})}),x(this,"onResizeStop",(l,c,d,h)=>{let{e:y,node:p}=h;const{layout:g,oldResizeItem:f}=this.state,{cols:S,allowOverlap:N}=this.props,O=(0,s.getLayoutItem)(g,l),R=N?g:(0,s.compact)(g,(0,s.compactType)(this.props),S);this.props.onResizeStop(R,f,O,null,y,p);const{oldLayout:M}=this.state;this.setState({activeDrag:null,layout:R,oldResizeItem:null,oldLayout:null,resizing:!1}),this.onLayoutMaybeChanged(R,M)}),x(this,"onDragOver",l=>{if(l.preventDefault(),l.stopPropagation(),P&&!l.nativeEvent.target?.classList.contains(j))return!1;const{droppingItem:c,onDropDragOver:d,margin:h,cols:y,rowHeight:p,maxRows:g,width:f,containerPadding:S,transformScale:N}=this.props,O=d?.(l);if(O===!1)return this.state.droppingDOMNode&&this.removeDroppingPlaceholder(),!1;const R={...c,...O},{layout:M}=this.state,D=l.currentTarget.getBoundingClientRect(),q=l.clientX-D.left,T=l.clientY-D.top,z={left:q/N,top:T/N,e:l};if(this.state.droppingDOMNode){if(this.state.droppingPosition){const{left:A,top:U}=this.state.droppingPosition;(A!=q||U!=T)&&this.setState({droppingPosition:z})}}else{const A={cols:y,margin:h,maxRows:g,rowHeight:p,containerWidth:f,containerPadding:S||h},U=(0,a.calcXY)(A,T,q,R.w,R.h);this.setState({droppingDOMNode:t.createElement("div",{key:R.i}),droppingPosition:z,layout:[...M,{...R,x:U.x,y:U.y,static:!1,isDraggable:!0}]})}}),x(this,"removeDroppingPlaceholder",()=>{const{droppingItem:l,cols:c}=this.props,{layout:d}=this.state,h=(0,s.compact)(d.filter(y=>y.i!==l.i),(0,s.compactType)(this.props),c,this.props.allowOverlap);this.setState({layout:h,droppingDOMNode:null,activeDrag:null,droppingPosition:void 0})}),x(this,"onDragLeave",l=>{l.preventDefault(),l.stopPropagation(),this.dragEnterCounter--,this.dragEnterCounter===0&&this.removeDroppingPlaceholder()}),x(this,"onDragEnter",l=>{l.preventDefault(),l.stopPropagation(),this.dragEnterCounter++}),x(this,"onDrop",l=>{l.preventDefault(),l.stopPropagation();const{droppingItem:c}=this.props,{layout:d}=this.state,h=d.find(y=>y.i===c.i);this.dragEnterCounter=0,this.removeDroppingPlaceholder(),this.props.onDrop(d,h,l)})}componentDidMount(){this.setState({mounted:!0}),this.onLayoutMaybeChanged(this.state.layout,this.props.layout)}static getDerivedStateFromProps(l,c){let d;return c.activeDrag?null:(!(0,n.deepEqual)(l.layout,c.propsLayout)||l.compactType!==c.compactType?d=l.layout:(0,s.childrenEqual)(l.children,c.children)||(d=c.layout),d?{layout:(0,s.synchronizeLayoutWithChildren)(d,l.children,l.cols,(0,s.compactType)(l),l.allowOverlap),compactType:l.compactType,children:l.children,propsLayout:l.layout}:null)}shouldComponentUpdate(l,c){return this.props.children!==l.children||!(0,s.fastRGLPropsEqual)(this.props,l,n.deepEqual)||this.state.activeDrag!==c.activeDrag||this.state.mounted!==c.mounted||this.state.droppingPosition!==c.droppingPosition}componentDidUpdate(l,c){if(!this.state.activeDrag){const d=this.state.layout,h=c.layout;this.onLayoutMaybeChanged(d,h)}}containerHeight(){if(!this.props.autoSize)return;const l=(0,s.bottom)(this.state.layout),c=this.props.containerPadding?this.props.containerPadding[1]:this.props.margin[1];return l*this.props.rowHeight+(l-1)*this.props.margin[1]+c*2+"px"}onLayoutMaybeChanged(l,c){c||(c=this.state.layout),(0,n.deepEqual)(c,l)||this.props.onLayoutChange(l)}placeholder(){const{activeDrag:l}=this.state;if(!l)return null;const{width:c,cols:d,margin:h,containerPadding:y,rowHeight:p,maxRows:g,useCSSTransforms:f,transformScale:S}=this.props;return t.createElement(i.default,{w:l.w,h:l.h,x:l.x,y:l.y,i:l.i,className:`react-grid-placeholder ${this.state.resizing?"placeholder-resizing":""}`,containerWidth:c,cols:d,margin:h,containerPadding:y||h,maxRows:g,rowHeight:p,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:f,transformScale:S},t.createElement("div",null))}processGridItem(l,c){if(!l||!l.key)return;const d=(0,s.getLayoutItem)(this.state.layout,String(l.key));if(!d)return null;const{width:h,cols:y,margin:p,containerPadding:g,rowHeight:f,maxRows:S,isDraggable:N,isResizable:O,isBounded:R,useCSSTransforms:M,transformScale:D,draggableCancel:q,draggableHandle:T,resizeHandles:z,resizeHandle:A}=this.props,{mounted:U,droppingPosition:X}=this.state,V=typeof d.isDraggable=="boolean"?d.isDraggable:!d.static&&N,le=typeof d.isResizable=="boolean"?d.isResizable:!d.static&&O,de=d.resizeHandles||z,Q=V&&R&&d.isBounded!==!1;return t.createElement(i.default,{containerWidth:h,cols:y,margin:p,containerPadding:g||p,maxRows:S,rowHeight:f,cancel:q,handle:T,onDragStop:this.onDragStop,onDragStart:this.onDragStart,onDrag:this.onDrag,onResizeStart:this.onResizeStart,onResize:this.onResize,onResizeStop:this.onResizeStop,isDraggable:V,isResizable:le,isBounded:Q,useCSSTransforms:M&&U,usePercentages:!U,transformScale:D,w:d.w,h:d.h,x:d.x,y:d.y,i:d.i,minH:d.minH,minW:d.minW,maxH:d.maxH,maxW:d.maxW,static:d.static,droppingPosition:c?X:void 0,resizeHandles:de,resizeHandle:A},l)}render(){const{className:l,style:c,isDroppable:d,innerRef:h}=this.props,y=(0,r.default)(j,l),p={height:this.containerHeight(),...c};return t.createElement("div",{ref:h,className:y,style:p,onDrop:d?this.onDrop:s.noop,onDragLeave:d?this.onDragLeave:s.noop,onDragEnter:d?this.onDragEnter:s.noop,onDragOver:d?this.onDragOver:s.noop},t.Children.map(this.props.children,g=>this.processGridItem(g)),d&&this.state.droppingDOMNode&&this.processGridItem(this.state.droppingDOMNode,!0),this.placeholder())}};return Et.default=w,x(w,"displayName","ReactGridLayout"),x(w,"propTypes",o.default),x(w,"defaultProps",{autoSize:!0,cols:12,className:"",style:{},draggableHandle:"",draggableCancel:"",containerPadding:null,rowHeight:150,maxRows:1/0,layout:[],margin:[10,10],isBounded:!1,isDraggable:!0,isResizable:!0,allowOverlap:!1,isDroppable:!1,useCSSTransforms:!0,transformScale:1,verticalCompact:!0,compactType:"vertical",preventCollision:!1,droppingItem:{i:"__dropping-elem__",h:1,w:1},resizeHandles:["se"],onLayoutChange:s.noop,onDragStart:s.noop,onDrag:s.noop,onDragStop:s.noop,onResizeStart:s.noop,onResize:s.noop,onResizeStop:s.noop,onDrop:s.noop,onDropDragOver:s.noop}),Et}var Lt={},ot={},po;function Tu(){if(po)return ot;po=1,Object.defineProperty(ot,"__esModule",{value:!0}),ot.findOrGenerateResponsiveLayout=s,ot.getBreakpointFromWidth=n,ot.getColsFromBreakpoint=r,ot.sortBreakpoints=a;var t=Ct();function n(i,o){const u=a(i);let v=u[0];for(let x=1,_=u.length;x<_;x++){const b=u[x];o>i[b]&&(v=b)}return v}function r(i,o){if(!o[i])throw new Error("ResponsiveReactGridLayout: `cols` entry for breakpoint "+i+" is missing!");return o[i]}function s(i,o,u,v,x,_){if(i[u])return(0,t.cloneLayout)(i[u]);let b=i[v];const j=a(o),P=j.slice(j.indexOf(u));for(let w=0,m=P.length;w<m;w++){const l=P[w];if(i[l]){b=i[l];break}}return b=(0,t.cloneLayout)(b||[]),(0,t.compact)((0,t.correctBounds)(b,{cols:x}),_,x)}function a(i){return Object.keys(i).sort(function(u,v){return i[u]-i[v]})}return ot}var mo;function hf(){if(mo)return Lt;mo=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.default=void 0;var t=u(Fe()),n=o(it()),r=ti(),s=Ct(),a=Tu(),i=o(qu());function o(m){return m&&m.__esModule?m:{default:m}}function u(m,l){if(typeof WeakMap=="function")var c=new WeakMap,d=new WeakMap;return(u=function(h,y){if(!y&&h&&h.__esModule)return h;var p,g,f={__proto__:null,default:h};if(h===null||typeof h!="object"&&typeof h!="function")return f;if(p=y?d:c){if(p.has(h))return p.get(h);p.set(h,f)}for(const S in h)S!=="default"&&{}.hasOwnProperty.call(h,S)&&((g=(p=Object.defineProperty)&&Object.getOwnPropertyDescriptor(h,S))&&(g.get||g.set)?p(f,S,g):f[S]=h[S]);return f})(m,l)}function v(){return v=Object.assign?Object.assign.bind():function(m){for(var l=1;l<arguments.length;l++){var c=arguments[l];for(var d in c)({}).hasOwnProperty.call(c,d)&&(m[d]=c[d])}return m},v.apply(null,arguments)}function x(m,l,c){return(l=_(l))in m?Object.defineProperty(m,l,{value:c,enumerable:!0,configurable:!0,writable:!0}):m[l]=c,m}function _(m){var l=b(m,"string");return typeof l=="symbol"?l:l+""}function b(m,l){if(typeof m!="object"||!m)return m;var c=m[Symbol.toPrimitive];if(c!==void 0){var d=c.call(m,l);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(l==="string"?String:Number)(m)}const j=m=>Object.prototype.toString.call(m);function P(m,l){return m==null?null:Array.isArray(m)?m:m[l]}let w=class extends t.Component{constructor(){super(...arguments),x(this,"state",this.generateInitialState()),x(this,"onLayoutChange",l=>{this.props.onLayoutChange(l,{...this.props.layouts,[this.state.breakpoint]:l})})}generateInitialState(){const{width:l,breakpoints:c,layouts:d,cols:h}=this.props,y=(0,a.getBreakpointFromWidth)(c,l),p=(0,a.getColsFromBreakpoint)(y,h),g=this.props.verticalCompact===!1?null:this.props.compactType;return{layout:(0,a.findOrGenerateResponsiveLayout)(d,c,y,y,p,g),breakpoint:y,cols:p}}static getDerivedStateFromProps(l,c){if(!(0,r.deepEqual)(l.layouts,c.layouts)){const{breakpoint:d,cols:h}=c;return{layout:(0,a.findOrGenerateResponsiveLayout)(l.layouts,l.breakpoints,d,d,h,l.compactType),layouts:l.layouts}}return null}componentDidUpdate(l){(this.props.width!=l.width||this.props.breakpoint!==l.breakpoint||!(0,r.deepEqual)(this.props.breakpoints,l.breakpoints)||!(0,r.deepEqual)(this.props.cols,l.cols))&&this.onWidthChange(l)}onWidthChange(l){const{breakpoints:c,cols:d,layouts:h,compactType:y}=this.props,p=this.props.breakpoint||(0,a.getBreakpointFromWidth)(this.props.breakpoints,this.props.width),g=this.state.breakpoint,f=(0,a.getColsFromBreakpoint)(p,d),S={...h};if(g!==p||l.breakpoints!==c||l.cols!==d){g in S||(S[g]=(0,s.cloneLayout)(this.state.layout));let R=(0,a.findOrGenerateResponsiveLayout)(S,c,p,g,f,y);R=(0,s.synchronizeLayoutWithChildren)(R,this.props.children,f,y,this.props.allowOverlap),S[p]=R,this.props.onBreakpointChange(p,f),this.props.onLayoutChange(R,S),this.setState({breakpoint:p,layout:R,cols:f})}const N=P(this.props.margin,p),O=P(this.props.containerPadding,p);this.props.onWidthChange(this.props.width,N,f,O)}render(){const{breakpoint:l,breakpoints:c,cols:d,layouts:h,margin:y,containerPadding:p,onBreakpointChange:g,onLayoutChange:f,onWidthChange:S,...N}=this.props;return t.createElement(i.default,v({},N,{margin:P(y,this.state.breakpoint),containerPadding:P(p,this.state.breakpoint),onLayoutChange:this.onLayoutChange,layout:this.state.layout,cols:this.state.cols}))}};return Lt.default=w,x(w,"propTypes",{breakpoint:n.default.string,breakpoints:n.default.object,allowOverlap:n.default.bool,cols:n.default.object,margin:n.default.oneOfType([n.default.array,n.default.object]),containerPadding:n.default.oneOfType([n.default.array,n.default.object]),layouts(m,l){if(j(m[l])!=="[object Object]")throw new Error("Layout property must be an object. Received: "+j(m[l]));Object.keys(m[l]).forEach(c=>{if(!(c in m.breakpoints))throw new Error("Each key in layouts must align with a key in breakpoints.");(0,s.validateLayout)(m.layouts[c],"layouts."+c)})},width:n.default.number.isRequired,onBreakpointChange:n.default.func,onLayoutChange:n.default.func,onWidthChange:n.default.func}),x(w,"defaultProps",{breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},containerPadding:{lg:null,md:null,sm:null,xs:null,xxs:null},layouts:{},margin:[10,10],allowOverlap:!1,onBreakpointChange:s.noop,onLayoutChange:s.noop,onWidthChange:s.noop}),Lt}var ur={},Lu=(function(){if(typeof Map<"u")return Map;function t(n,r){var s=-1;return n.some(function(a,i){return a[0]===r?(s=i,!0):!1}),s}return(function(){function n(){this.__entries__=[]}return Object.defineProperty(n.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),n.prototype.get=function(r){var s=t(this.__entries__,r),a=this.__entries__[s];return a&&a[1]},n.prototype.set=function(r,s){var a=t(this.__entries__,r);~a?this.__entries__[a][1]=s:this.__entries__.push([r,s])},n.prototype.delete=function(r){var s=this.__entries__,a=t(s,r);~a&&s.splice(a,1)},n.prototype.has=function(r){return!!~t(this.__entries__,r)},n.prototype.clear=function(){this.__entries__.splice(0)},n.prototype.forEach=function(r,s){s===void 0&&(s=null);for(var a=0,i=this.__entries__;a<i.length;a++){var o=i[a];r.call(s,o[1],o[0])}},n})()})(),Ia=typeof window<"u"&&typeof document<"u"&&window.document===document,xr=(function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()})(),ff=(function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(xr):function(t){return setTimeout(function(){return t(Date.now())},1e3/60)}})(),pf=2;function mf(t,n){var r=!1,s=!1,a=0;function i(){r&&(r=!1,t()),s&&u()}function o(){ff(i)}function u(){var v=Date.now();if(r){if(v-a<pf)return;s=!0}else r=!0,s=!1,setTimeout(o,n);a=v}return u}var gf=20,vf=["top","right","bottom","left","width","height","size","weight"],yf=typeof MutationObserver<"u",xf=(function(){function t(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=mf(this.refresh.bind(this),gf)}return t.prototype.addObserver=function(n){~this.observers_.indexOf(n)||this.observers_.push(n),this.connected_||this.connect_()},t.prototype.removeObserver=function(n){var r=this.observers_,s=r.indexOf(n);~s&&r.splice(s,1),!r.length&&this.connected_&&this.disconnect_()},t.prototype.refresh=function(){var n=this.updateObservers_();n&&this.refresh()},t.prototype.updateObservers_=function(){var n=this.observers_.filter(function(r){return r.gatherActive(),r.hasActive()});return n.forEach(function(r){return r.broadcastActive()}),n.length>0},t.prototype.connect_=function(){!Ia||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),yf?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},t.prototype.disconnect_=function(){!Ia||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},t.prototype.onTransitionEnd_=function(n){var r=n.propertyName,s=r===void 0?"":r,a=vf.some(function(i){return!!~s.indexOf(i)});a&&this.refresh()},t.getInstance=function(){return this.instance_||(this.instance_=new t),this.instance_},t.instance_=null,t})(),Iu=(function(t,n){for(var r=0,s=Object.keys(n);r<s.length;r++){var a=s[r];Object.defineProperty(t,a,{value:n[a],enumerable:!1,writable:!1,configurable:!0})}return t}),jt=(function(t){var n=t&&t.ownerDocument&&t.ownerDocument.defaultView;return n||xr}),zu=Dr(0,0,0,0);function br(t){return parseFloat(t)||0}function go(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return n.reduce(function(s,a){var i=t["border-"+a+"-width"];return s+br(i)},0)}function bf(t){for(var n=["top","right","bottom","left"],r={},s=0,a=n;s<a.length;s++){var i=a[s],o=t["padding-"+i];r[i]=br(o)}return r}function jf(t){var n=t.getBBox();return Dr(0,0,n.width,n.height)}function wf(t){var n=t.clientWidth,r=t.clientHeight;if(!n&&!r)return zu;var s=jt(t).getComputedStyle(t),a=bf(s),i=a.left+a.right,o=a.top+a.bottom,u=br(s.width),v=br(s.height);if(s.boxSizing==="border-box"&&(Math.round(u+i)!==n&&(u-=go(s,"left","right")+i),Math.round(v+o)!==r&&(v-=go(s,"top","bottom")+o)),!_f(t)){var x=Math.round(u+i)-n,_=Math.round(v+o)-r;Math.abs(x)!==1&&(u-=x),Math.abs(_)!==1&&(v-=_)}return Dr(a.left,a.top,u,v)}var Sf=(function(){return typeof SVGGraphicsElement<"u"?function(t){return t instanceof jt(t).SVGGraphicsElement}:function(t){return t instanceof jt(t).SVGElement&&typeof t.getBBox=="function"}})();function _f(t){return t===jt(t).document.documentElement}function Cf(t){return Ia?Sf(t)?jf(t):wf(t):zu}function Rf(t){var n=t.x,r=t.y,s=t.width,a=t.height,i=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,o=Object.create(i.prototype);return Iu(o,{x:n,y:r,width:s,height:a,top:r,right:n+s,bottom:a+r,left:n}),o}function Dr(t,n,r,s){return{x:t,y:n,width:r,height:s}}var Nf=(function(){function t(n){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=Dr(0,0,0,0),this.target=n}return t.prototype.isActive=function(){var n=Cf(this.target);return this.contentRect_=n,n.width!==this.broadcastWidth||n.height!==this.broadcastHeight},t.prototype.broadcastRect=function(){var n=this.contentRect_;return this.broadcastWidth=n.width,this.broadcastHeight=n.height,n},t})(),Pf=(function(){function t(n,r){var s=Rf(r);Iu(this,{target:n,contentRect:s})}return t})(),Ef=(function(){function t(n,r,s){if(this.activeObservations_=[],this.observations_=new Lu,typeof n!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=n,this.controller_=r,this.callbackCtx_=s}return t.prototype.observe=function(n){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(n instanceof jt(n).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(n)||(r.set(n,new Nf(n)),this.controller_.addObserver(this),this.controller_.refresh())}},t.prototype.unobserve=function(n){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(n instanceof jt(n).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(n)&&(r.delete(n),r.size||this.controller_.removeObserver(this))}},t.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},t.prototype.gatherActive=function(){var n=this;this.clearActive(),this.observations_.forEach(function(r){r.isActive()&&n.activeObservations_.push(r)})},t.prototype.broadcastActive=function(){if(this.hasActive()){var n=this.callbackCtx_,r=this.activeObservations_.map(function(s){return new Pf(s.target,s.broadcastRect())});this.callback_.call(n,r,n),this.clearActive()}},t.prototype.clearActive=function(){this.activeObservations_.splice(0)},t.prototype.hasActive=function(){return this.activeObservations_.length>0},t})(),Hu=typeof WeakMap<"u"?new WeakMap:new Lu,Wu=(function(){function t(n){if(!(this instanceof t))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=xf.getInstance(),s=new Ef(n,r,this);Hu.set(this,s)}return t})();["observe","unobserve","disconnect"].forEach(function(t){Wu.prototype[t]=function(){var n;return(n=Hu.get(this))[t].apply(n,arguments)}});var kf=(function(){return typeof xr.ResizeObserver<"u"?xr.ResizeObserver:Wu})();const Mf=Object.freeze(Object.defineProperty({__proto__:null,default:kf},Symbol.toStringTag,{value:"Module"})),Of=ph(Mf);var vo;function Df(){if(vo)return ur;vo=1,Object.defineProperty(ur,"__esModule",{value:!0}),ur.default=b;var t=i(Fe()),n=a(it()),r=a(Of),s=a(Mr());function a(j){return j&&j.__esModule?j:{default:j}}function i(j,P){if(typeof WeakMap=="function")var w=new WeakMap,m=new WeakMap;return(i=function(l,c){if(!c&&l&&l.__esModule)return l;var d,h,y={__proto__:null,default:l};if(l===null||typeof l!="object"&&typeof l!="function")return y;if(d=c?m:w){if(d.has(l))return d.get(l);d.set(l,y)}for(const p in l)p!=="default"&&{}.hasOwnProperty.call(l,p)&&((h=(d=Object.defineProperty)&&Object.getOwnPropertyDescriptor(l,p))&&(h.get||h.set)?d(y,p,h):y[p]=l[p]);return y})(j,P)}function o(){return o=Object.assign?Object.assign.bind():function(j){for(var P=1;P<arguments.length;P++){var w=arguments[P];for(var m in w)({}).hasOwnProperty.call(w,m)&&(j[m]=w[m])}return j},o.apply(null,arguments)}function u(j,P,w){return(P=v(P))in j?Object.defineProperty(j,P,{value:w,enumerable:!0,configurable:!0,writable:!0}):j[P]=w,j}function v(j){var P=x(j,"string");return typeof P=="symbol"?P:P+""}function x(j,P){if(typeof j!="object"||!j)return j;var w=j[Symbol.toPrimitive];if(w!==void 0){var m=w.call(j,P);if(typeof m!="object")return m;throw new TypeError("@@toPrimitive must return a primitive value.")}return(P==="string"?String:Number)(j)}const _="react-grid-layout";function b(j){var P;return P=class extends t.Component{constructor(){super(...arguments),u(this,"state",{width:1280}),u(this,"elementRef",t.createRef()),u(this,"mounted",!1),u(this,"resizeObserver",void 0)}componentDidMount(){this.mounted=!0,this.resizeObserver=new r.default(l=>{if(this.elementRef.current instanceof HTMLElement){const d=l[0].contentRect.width;this.setState({width:d})}});const m=this.elementRef.current;m instanceof HTMLElement&&this.resizeObserver.observe(m)}componentWillUnmount(){this.mounted=!1;const m=this.elementRef.current;m instanceof HTMLElement&&this.resizeObserver.unobserve(m),this.resizeObserver.disconnect()}render(){const{measureBeforeMount:m,...l}=this.props;return m&&!this.mounted?t.createElement("div",{className:(0,s.default)(this.props.className,_),style:this.props.style,ref:this.elementRef}):t.createElement(j,o({innerRef:this.elementRef},l,this.state))}},u(P,"defaultProps",{measureBeforeMount:!1}),u(P,"propTypes",{measureBeforeMount:n.default.bool}),P}return ur}var yo;function Af(){return yo||(yo=1,(function(t){t.exports=qu().default,t.exports.utils=Ct(),t.exports.calculateUtils=ri(),t.exports.Responsive=hf().default,t.exports.Responsive.utils=Tu(),t.exports.WidthProvider=Df().default})(Xr)),Xr.exports}var qf=Af();const Tf=Xa(qf),Lf=()=>{const t=ie(te.ChatSend),[n,r]=C.useState([]),[s,a]=C.useState(""),i=C.useRef(null),o=Y.chat.send.useMutation(),u=()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},v=ie(te.ChatRecent),{data:x}=Y.chat.recent.useQuery(void 0,{enabled:v});C.useEffect(()=>{x&&r(x.slice().reverse())},[x]),Y.chat.onMessage.useSubscription(void 0,{enabled:v,onError:ut,onData:b=>{r(j=>{const P=[...j,b];return P.length>50?P.slice(P.length-50):P})}}),C.useLayoutEffect(()=>{u()},[n]);const _=b=>{b.preventDefault(),!(s.length>140||s.length===0)&&(o.mutate(s),a(""))};return e.jsxs("div",{className:"chat-widget",children:[e.jsx(Pe,{className:"messages",ref:i,children:e.jsx("div",{className:"messages-child",children:n.map(b=>e.jsxs("div",{className:"log-entry",children:[b.action==="msg"&&e.jsxs("div",{className:"chat-message",children:[b.user?.web?"[":"",e.jsx(Ur,{color:!0,user:b.user}),b.user?.web?"]":"",":"," ",e.jsx(yi,{as:"span",children:b.message})]}),b.action==="leave"&&e.jsxs("div",{className:"join-message",children:[e.jsx(Ur,{user:b.user})," left the game."]}),b.action==="join"&&e.jsxs("div",{className:"join-message",children:[e.jsx(Ur,{user:b.user})," joined the game",b.user?.isFirst?" for the first time":"","."]}),b.action==="server"&&e.jsx(yi,{as:"div",className:"server-message",children:b.message})]},b._id))})}),t&&e.jsx("form",{onSubmit:_,children:e.jsxs(Oe,{children:[e.jsx(me,{roboto:!0,type:"text",placeholder:"Message",value:s,onChange:b=>a(b)}),e.jsx(F,{normal:!0,icon:!0,style:{marginLeft:"10px"},onClick:_,children:e.jsx(Bd,{})})]})})]})},If=()=>{const t=ie(te.ServerStatus),n=ie(te.PlayerList),[r,s]=C.useState(null),{data:a}=Y.server.status.useQuery(void 0,{enabled:t});return C.useEffect(()=>{a&&!r&&s(a)},[a]),Y.server.onHeartbeat.useSubscription(void 0,{enabled:t,onError:ut,onData:s}),e.jsxs("div",{className:"status-widget",children:[r?.players&&e.jsxs("div",{className:"players",children:[e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Name:"})," ",r.serverName]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Uptime:"})," ",Me(r.time)]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Bricks:"})," ",r.bricks]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Players:"})," ",r.players.length]})]}),e.jsx(Pe,{className:"player-table",children:e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",width:"100%"},children:"Name"}),e.jsx("th",{children:"Time"}),e.jsx("th",{children:"Ping"})]})}),e.jsx("tbody",{children:r.players.map(i=>e.jsxs("tr",{children:[e.jsx("td",{children:n?e.jsx(xt,{className:"user",to:"/players/"+i.id,children:i.name}):e.jsx("span",{className:"user",children:i.name})}),e.jsx("td",{style:{textAlign:"right"},children:Me(i.time)}),e.jsx("td",{style:{textAlign:"right"},children:i.ping})]},i.address+i.id))})]})})]}),!r?.players&&e.jsx(xe,{blur:!0,size:"huge",children:"Loading Status"})]})},xo=30;function dr(t){return t<1024?`${t} B`:t<1024**2?`${(t/1024).toFixed(1)} KB`:t<1024**3?`${(t/1024**2).toFixed(1)} MB`:`${(t/1024**3).toFixed(1)} GB`}function bo(t){return t<1024?`${Math.round(t)} B/s`:t<1024**2?`${(t/1024).toFixed(1)} KB/s`:`${(t/1024**2).toFixed(1)} MB/s`}function tn(t){return t.length>=xo?t:[...new Array(xo-t.length).fill(t[0]??0),...t]}const rn=({value:t,color:n})=>{const s=Math.PI*2*36,a=Math.max(0,Math.min(100,t));return e.jsxs("svg",{viewBox:"0 0 100 100",className:"donut-svg",children:[e.jsx("circle",{cx:"50",cy:"50",r:36,fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:"8"}),e.jsx("circle",{cx:"50",cy:"50",r:36,fill:"none",stroke:n,strokeWidth:"8",strokeDasharray:`${a/100*s} ${s}`,strokeLinecap:"round",transform:"rotate(-90 50 50)",style:{transition:"stroke-dasharray 0.5s ease"}}),e.jsx("text",{x:"50",y:"50",textAnchor:"middle",dominantBaseline:"central",className:"donut-pct",children:Math.round(a)===100?"100":`${Math.round(a)}%`})]})},nn=({data:t,color:n,height:r=32,width:s=120})=>{if(t.length<2)return null;const a=Math.max(...t,1),i=s/(t.length-1),o=t.map((v,x)=>`${x*i},${r-v/a*(r-2)-1}`).join(" "),u=`0,${r} ${o} ${s},${r}`;return e.jsxs("svg",{viewBox:`0 0 ${s} ${r}`,className:"sparkline",preserveAspectRatio:"none",children:[e.jsx("polygon",{points:u,fill:n,fillOpacity:"0.12"}),e.jsx("polyline",{points:o,fill:"none",stroke:n,strokeWidth:"1.5",strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})},zf=()=>{const[t,n]=C.useState(null),r=C.useRef([]),s=C.useRef([]),a=C.useRef([]),[,i]=C.useState(0),o=C.useCallback(w=>{n(w),r.current=[...r.current.slice(-29),w.cpu],s.current=[...s.current.slice(-29),w.net.rxSec],a.current=[...a.current.slice(-29),w.net.txSec],i(m=>m+1)},[]),u=ie(te.ServerUtilization),{data:v}=Y.server.utilization.useQuery(void 0,{enabled:u});if(C.useEffect(()=>{if(!v)return;const w=v.history;w.length>0&&(r.current=w.map(m=>m.cpu),s.current=w.map(m=>m.net.rxSec),a.current=w.map(m=>m.net.txSec)),v.current&&!t&&n(v.current),i(m=>m+1)},[v]),Y.server.onUtilization.useSubscription(void 0,{enabled:u,onError:ut,onData:o}),!t)return e.jsx("div",{className:"utilization-widget",children:e.jsx(xe,{blur:!0,size:"huge",children:"Waiting for metrics..."})});const x=t.cpu>80?"#e02d2d":t.cpu>50?"#ffa10b":"#5da93d",_=t.mem.used/t.mem.total*100,b=_>80?"#e02d2d":_>50?"#ffa10b":"#009bee",j=t.disk.used/t.disk.total*100,P=j>90?"#e02d2d":j>70?"#ffa10b":"#009bee";return e.jsxs("div",{className:"utilization-widget",children:[e.jsxs("div",{className:"util-donuts",children:[e.jsxs("div",{className:"donut-row",children:[e.jsx(rn,{value:t.cpu,color:x}),e.jsx("div",{className:"donut-detail",children:e.jsx("b",{children:"CPU"})})]}),e.jsxs("div",{className:"donut-row",children:[e.jsx(rn,{value:_,color:b}),e.jsxs("div",{className:"donut-detail",children:[e.jsx("b",{children:"MEMORY"}),e.jsxs("div",{className:"donut-detail-line",children:[e.jsx("span",{children:dr(t.mem.used)}),e.jsxs("span",{className:"donut-detail-sub",children:["/ ",dr(t.mem.total)]})]})]})]}),e.jsxs("div",{className:"donut-row",children:[e.jsx(rn,{value:j,color:P}),e.jsxs("div",{className:"donut-detail",children:[e.jsx("b",{children:"STORAGE"}),e.jsxs("div",{className:"donut-detail-line",children:[e.jsx("span",{children:dr(t.disk.used)}),e.jsxs("span",{className:"donut-detail-sub",children:["/ ",dr(t.disk.total)]})]})]})]})]}),e.jsxs("div",{className:"util-sparklines",children:[e.jsxs("div",{className:"spark-row",children:[e.jsxs("span",{className:"spark-label",children:[e.jsx(Ud,{size:14}),"CPU"]}),e.jsx(nn,{data:tn(r.current),color:x}),e.jsxs("span",{className:"spark-value",children:[t.cpu,"%"]})]}),e.jsxs("div",{className:"spark-row",children:[e.jsxs("span",{className:"spark-label",children:[e.jsx(cu,{size:14}),"RX"]}),e.jsx(nn,{data:tn(s.current),color:"#009bee"}),e.jsx("span",{className:"spark-value",children:bo(t.net.rxSec)})]}),e.jsxs("div",{className:"spark-row",children:[e.jsxs("span",{className:"spark-label",children:[e.jsx(lu,{size:14}),"TX"]}),e.jsx(nn,{data:tn(a.current),color:"#5da93d"}),e.jsx("span",{className:"spark-value",children:bo(t.net.txSec)})]})]})]})},jo={chat:{component:Lf,icon:Gd,tooltip:"Chat with online players",scope:te.ChatRecent},status:{component:If,icon:hh,tooltip:"View current online players and server status",scope:te.ServerStatus},utilization:{component:zf,icon:$d,tooltip:"View CPU, memory, disk, and network usage",scope:te.ServerUtilization}},wo=[{x:0,y:0,w:4,h:4,i:"chat"},{x:4,y:0,w:4,h:4,i:"status"}],Hf=["status","chat","utilization"],Wf={minW:2,maxW:10,minH:2,maxH:10},Ff=[8,8],Bf=()=>{const t=ie(te.ChatRecent),n=ie(te.ServerStatus),r=ie(te.ServerUtilization),s=C.useMemo(()=>{const h={};return t&&(h.chat=!0),n&&(h.status=!0),r&&(h.utilization=!0),h},[t,n,r]),a=t||n||r,i=Md(),o=C.useMemo(()=>{const h={};for(const[y,p]of Object.entries(jo))s[y]&&(h[y]=p);return h},[s]),[u,v]=C.useState(()=>{if(localStorage.omeggaDashLayout2)try{return JSON.parse(localStorage.omeggaDashLayout2)}catch(h){return console.error("Invalid layout in localStorage, using default layout",h),wo}return wo}),x=C.useMemo(()=>u.filter(h=>s[h.i]),[u,s]);C.useEffect(()=>{localStorage.omeggaDashLayout2=JSON.stringify(u)},[u]);const _=h=>{v(u.filter(y=>y.i!==h))},b=h=>{h in o&&v([...u,{x:0,y:0,w:4,h:4,i:h}])},[j,P]=C.useState(!1),w=Object.fromEntries(u.map(h=>[h.i,!0])),m=C.useCallback(h=>{v(h)},[]),l=C.useRef(null),[c,d]=C.useState(null);return C.useEffect(()=>{l.current&&d(l.current.clientWidth);const h=new ResizeObserver(y=>{for(const p of y)p.target===l.current&&d(p.contentRect.width)});return l.current&&h.observe(l.current),()=>{h.disconnect()}},[l.current]),e.jsxs(e.Fragment,{children:[!i&&e.jsx(ze,{title:"Dashboard",children:a&&e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":"Add more widgets to the dashboard",onClick:()=>P(!j),children:[e.jsx(uu,{}),"Widgets"]}),e.jsx(Ve,{visible:j,children:Object.entries(o).map(([h,y])=>e.jsxs("div",{className:"widget-item",children:[e.jsxs("div",{className:"name","data-tooltip":y.tooltip,children:[e.jsx(y.icon,{}),h]}),w[h]?e.jsx(F,{warn:!0,icon:!0,"data-tooltip":`Remove ${h} widget`,onClick:()=>_(h),children:e.jsx(Ka,{})}):e.jsx(F,{main:!0,icon:!0,"data-tooltip":`Add ${h} widget`,onClick:()=>b(h),children:e.jsx(nt,{})})]},h))})]})}),e.jsxs(He,{children:[e.jsx(We,{}),i?a?e.jsx("div",{className:"widget-pager",children:Hf.filter(h=>s[h]).map(h=>{const y=jo[h],p=y.component;return e.jsxs("div",{className:"widget-page",children:[e.jsxs(Xe,{className:"widget-page-header",children:[e.jsx(y.icon,{}),h]}),e.jsx("div",{className:"widget-page-contents",children:e.jsx(p,{})})]},h)})}):e.jsx("div",{className:"grid-container",children:e.jsx("div",{className:"no-permissions-message",children:"Contact your admin for support"})}):e.jsxs("div",{className:"grid-container",ref:l,children:[!a&&e.jsx("div",{className:"no-permissions-message",children:"Contact your admin for support"}),a&&c!==null&&e.jsx(Tf,{layout:x.map(h=>({...h,...Wf})),width:c,cols:10,autoSize:!0,useCSSTransforms:!0,rowHeight:100,isBounded:!0,isResizable:!0,isDraggable:!0,margin:Ff,onLayoutChange:m,draggableHandle:".drag-handle",draggableCancel:".no-drag",resizeHandles:["se"],resizeHandle:e.jsx(Yd,{style:{cursor:"se-resize"},className:"resize-handle"}),children:x.map(h=>{const y=o[h.i]?.component;return y?e.jsxs("div",{className:"grid-item",children:[e.jsxs(Xe,{className:"drag-handle",children:[e.jsx("span",{style:{flex:1},children:h.i}),e.jsx(F,{icon:!0,error:!0,className:"no-drag","data-tooltip":"Close widget",onClick:()=>_(h.i),children:e.jsx(De,{})})]}),e.jsx("div",{className:"drag-contents",children:e.jsx(y,{})})]},h.i):null})})]})]})]})},So=["","k","M","G","T"];function wt(t){if(!Number.isFinite(t))return"";const n=Math.abs(t);if(n<1e3)return n===0?"0":n<1?t.toFixed(n<.1?3:2).replace(/\.?0+$/,""):String(Math.round(t*100)/100);let r=t,s=0;for(;Math.abs(r)>=1e3&&s<So.length-1;)r/=1e3,s++;return`${Math.round(r*10)/10}${So[s]}`}function za(t){if(!Number.isFinite(t))return"";const n=["B","KB","MB","GB","TB"];let r=t,s=0;for(;Math.abs(r)>=1024&&s<n.length-1;)r/=1024,s++;return`${s===0?Math.round(r):(Math.round(r*10)/10).toFixed(1)} ${n[s]}`}function Fu(t){if(!Number.isFinite(t))return"";if(t<1)return`${Math.round(t*1e3)}ms`;if(t<60)return`${Math.round(t*10)/10}s`;const n=[["d",86400],["h",3600],["m",60],["s",1]],r=[];let s=Math.floor(t);for(const[a,i]of n){const o=Math.floor(s/i);if(s-=o*i,(o>0||r.length>0)&&r.push(`${o}${a}`),r.length===2)break}return r.join(" ")||"0s"}function Ha(t,n){if(!Number.isFinite(t))return"n/a";switch(n){case"bytes":return za(t);case"bytesPerSecond":return`${za(t)}/s`;case"seconds":return t<1?`${Math.round(t*1e3)}ms`:`${Math.round(t*100)/100}s`;case"duration":return Fu(t);case"ratio":return`${Math.round(t*1e3)/10}%`;case"perHour":return`${wt(t)}/hr`;case"bool":return t?"YES":"NO";case"timestamp":return t>0?new Date(t*1e3).toLocaleString():"never";default:return wt(t)}}function Wa(t,n){switch(n){case"bytes":case"bytesPerSecond":return za(t);case"duration":return Fu(t);case"ratio":return`${Math.round(t*100)}%`;case"seconds":return t!==0&&t<1?`${Math.round(t*1e3)}ms`:`${wt(t)}s`;case"bool":return t===1?"YES":t===0?"NO":"";default:return wt(t)}}function Uf(t){return t<=36*3600*1e3?n=>new Date(n).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):t<=8*86400*1e3?n=>new Date(n).toLocaleString(void 0,{weekday:"short",hour:"2-digit"}):n=>new Date(n).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function Bu(t){if(!Number.isFinite(t)||t<=0)return 1;const n=Math.pow(10,Math.floor(Math.log10(t))),r=t/n;return(r<=1?1:r<=2?2:r<=5?5:10)*n}const _o=["#4cb9f3","#5da93d","#ffa10b","#e96c6c","#b06cf3","#00c2a8","#f36cb9","#a7bbce"];function jr(t){return _o[t%_o.length]}const $f=({bars:t,height:n=180})=>{const[r,s]=C.useState(null),a=Bu(Math.max(...t.map(o=>o.value),1)),i=jr(0);return e.jsxs("div",{className:"bar-chart",style:{height:n},children:[e.jsx("div",{className:"bar-chart-axis",children:[a,a/2,0].map(o=>e.jsx("span",{children:wt(o)},o))}),e.jsx("div",{className:"bar-chart-plot",children:t.map((o,u)=>e.jsxs("div",{className:`bar-column ${r===u?"hover":""}`,onMouseEnter:()=>s(u),onMouseLeave:()=>s(null),children:[e.jsxs("div",{className:"bar-track",children:[e.jsx("div",{className:"bar-fill",style:{height:`${o.value/a*100}%`,background:i}}),r===u&&e.jsxs("div",{className:"bar-tooltip",children:[e.jsx("div",{className:"bar-tooltip-value",children:wt(o.value)}),e.jsx("div",{className:"bar-tooltip-label",children:o.label})]})]}),e.jsx("span",{className:"bar-label",children:o.label})]},o.label))})]})},sn=120,It=16,Gf=({points:t,color:n=jr(0),domain:r})=>{const s=t.map(_=>_[1]).filter(Number.isFinite);if(s.length<2)return e.jsx("span",{className:"sparkline-empty"});const a=r?r[0]:Math.min(...s),o=(r?r[1]:Math.max(...s))-a||1,u=sn/(s.length-1),v=_=>It-1-(_-a)/o*(It-2),x=s.map((_,b)=>`${b===0?"M":"L"}${(b*u).toFixed(1)},${v(_).toFixed(1)}`).join("");return e.jsxs("svg",{className:"sparkline",viewBox:`0 0 ${sn} ${It}`,preserveAspectRatio:"none",children:[e.jsx("path",{d:`${x}L${sn},${It}L0,${It}Z`,fill:n,fillOpacity:.15,stroke:"none"}),e.jsx("path",{d:x,fill:"none",stroke:n,strokeWidth:1.5,strokeLinejoin:"round",vectorEffect:"non-scaling-stroke"})]})},qe={top:12,right:12,bottom:22,left:48},Co=4;function Yf(){const t=C.useRef(null),[n,r]=C.useState(0);return C.useEffect(()=>{const s=t.current;if(!s)return;r(s.clientWidth);const a=new ResizeObserver(i=>{for(const o of i)r(o.contentRect.width)});return a.observe(s),()=>a.disconnect()},[]),[t,n]}function Kf(t,n){const r=[];let s=[],a=null;for(const i of t){const[o,u]=i;if(!Number.isFinite(u)){s.length&&r.push(s),s=[],a=null;continue}a!=null&&o-a>n&&(s.length&&r.push(s),s=[]),s.push(i),a=o}return s.length&&r.push(s),r}function Xf(t,n,r){return t.map(s=>s.map(([a,i],o)=>`${o===0?"M":"L"}${n(a).toFixed(1)},${r(i).toFixed(1)}`).join("")).join("")}function Vf(t,n,r,s){return t.filter(a=>a.length>1).map(a=>{const i=a.map(([v,x],_)=>`${_===0?"M":"L"}${n(v).toFixed(1)},${r(x).toFixed(1)}`).join(""),o=n(a[a.length-1][0]).toFixed(1),u=n(a[0][0]).toFixed(1);return`${i}L${o},${s.toFixed(1)}L${u},${s.toFixed(1)}Z`}).join("")}const Qf=({series:t,unit:n,kind:r,height:s=180})=>{const[a,i]=Yf(),[o,u]=C.useState(null),[v,x]=C.useState(new Set),_=C.useMemo(()=>t.map((R,M)=>({s:R,index:M})).filter(({index:R})=>v.size===0||v.has(R)),[t,v]);C.useEffect(()=>{x(R=>{if(R.size===0)return R;const M=[...R].filter(D=>D<t.length);return M.length===R.size?R:new Set(M)})},[t.length]);const b=(R,M)=>{x(D=>{if(!M)return D.size===1&&D.has(R)?new Set:new Set([R]);const q=new Set(D);return q.has(R)?q.delete(R):q.add(R),q})},j=C.useMemo(()=>{const R=_.map(({s:Q})=>Q),M=R.flatMap(Q=>Q.points.map(he=>he[0]));if(M.length===0)return null;const D=Math.min(...M),q=Math.max(...M),T=r==="stacked",z=new Map;if(T)for(const Q of R)for(const[he,B]of Q.points)Number.isFinite(B)&&z.set(he,(z.get(he)??0)+B);const A=T?[...z.values()]:R.flatMap(Q=>Q.points.map(he=>he[1]).filter(Number.isFinite)),U=A.length?Math.max(...A):1,X=A.length?Math.min(...A):0,V=X>=0&&X<=U*.4,le=Bu(U||1);return{minTime:D,maxTime:q,min:V?0:X,max:le,stacked:T,totals:z}},[_,r]),P=Math.max(0,i-qe.left-qe.right),w=s-qe.top-qe.bottom,m=C.useCallback(R=>{if(!j)return 0;const M=j.maxTime-j.minTime||1;return qe.left+(R-j.minTime)/M*P},[j,P]),l=C.useCallback(R=>{if(!j)return 0;const M=j.max-j.min||1;return qe.top+w-(R-j.min)/M*w},[j,w]),c=C.useMemo(()=>{const R=_.find(({s:D})=>D.points.length>2)?.s;return R?(R.points[1][0]-R.points[0][0])*2.5:1/0},[_]),d=C.useCallback(R=>{if(!j||P<=0)return;const M=R.currentTarget.getBoundingClientRect(),D=(R.clientX-M.left-qe.left)/P;if(D<0||D>1)return u(null);u(j.minTime+D*(j.maxTime-j.minTime))},[j,P]);if(!j)return e.jsx("div",{className:"chart-empty",ref:a,children:"No data in this range"});const h=Uf(j.maxTime-j.minTime),y=Array.from({length:Co+1},(R,M)=>j.min+(j.max-j.min)*M/Co),p=Math.max(2,Math.min(6,Math.floor(P/90))),g=Array.from({length:p+1},(R,M)=>j.minTime+(j.maxTime-j.minTime)*M/p),f=new Map,S=_.map(({s:R,index:M})=>{const D=jr(M),q=j.stacked?R.points.map(([T,z])=>{if(!Number.isFinite(z))return[T,z];const A=f.get(T)??0;return f.set(T,A+z),[T,A+z]}):R.points;return{series:R,color:D,points:q}}),N=o==null?null:S.map(({series:R,color:M,points:D})=>{let q=-1,T=1/0;for(let z=0;z<R.points.length;z++){const A=Math.abs(R.points[z][0]-o);A<T&&(T=A,q=z)}return{name:R.name,color:M,point:q<0?null:R.points[q],drawnPoint:q<0?null:D[q]}}),O=N?.find(R=>R.point)?.point?.[0]??null;return e.jsxs("div",{className:"chart",ref:a,children:[i>0&&e.jsxs("svg",{width:i,height:s,onMouseMove:d,onMouseLeave:()=>u(null),children:[y.map(R=>e.jsxs("g",{children:[e.jsx("line",{x1:qe.left,x2:i-qe.right,y1:l(R),y2:l(R),className:"chart-grid"}),e.jsx("text",{x:qe.left-6,y:l(R),textAnchor:"end",dominantBaseline:"central",className:"chart-label",children:Wa(R,n)})]},R)),g.map((R,M)=>e.jsx("text",{x:m(R),y:s-6,textAnchor:M===0?"start":M===g.length-1?"end":"middle",className:"chart-label",children:h(R)},R)),S.map(({series:R,color:M,points:D},q)=>{const T=Kf(D,c);if(T.length===0)return null;const z=r==="area"||r==="stacked";return e.jsxs("g",{children:[z&&e.jsx("path",{d:Vf(T,m,l,l(j.min)),fill:M,fillOpacity:.15,stroke:"none"}),e.jsx("path",{d:Xf(T,m,l),fill:"none",stroke:M,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"})]},R.name+q)}),O!=null&&e.jsx("line",{x1:m(O),x2:m(O),y1:qe.top,y2:qe.top+w,className:"chart-crosshair"}),N?.map(({name:R,color:M,drawnPoint:D})=>D&&Number.isFinite(D[1])&&e.jsx("circle",{cx:m(D[0]),cy:l(D[1]),r:3,fill:M},R))]}),N&&O!=null&&e.jsxs("div",{className:`chart-tooltip ${m(O)>i/2?"left":"right"}`,children:[e.jsx("div",{className:"chart-tooltip-time",children:h(O)}),N.map(({name:R,color:M,point:D})=>e.jsxs("div",{className:"chart-tooltip-row",children:[e.jsx("span",{className:"chart-swatch",style:{background:M}}),e.jsx("span",{className:"chart-tooltip-name",children:R}),e.jsx("span",{className:"chart-tooltip-value",children:D?Ha(D[1],n):"n/a"})]},R))]}),t.length>1&&e.jsx("div",{className:"chart-legend",children:t.map((R,M)=>{const D=v.size>0&&!v.has(M);return e.jsxs("button",{type:"button",className:`chart-legend-item ${D?"dimmed":""}`,"data-tooltip":"Click to show only this series, shift-click to add another",onClick:q=>b(M,q.shiftKey),children:[e.jsx("span",{className:"chart-swatch",style:{background:jr(M)}}),R.name]},R.name+M)})})]})},Jf=t=>t.series.map(n=>({name:n.name,points:n.points.map(([r,s])=>[r*1e3,s])})),Zf=t=>{const n=t.series[0]?.points;return n?.length?n[n.length-1][1]:null};function ep(t,n){const r=t.series.map(o=>{const u=o.labels?.le??o.name;return{le:u==="+Inf"?1/0:Number(u),total:o.points[o.points.length-1]?.[1]??0}}).filter(o=>!Number.isNaN(o.le)&&Number.isFinite(o.total)).sort((o,u)=>o.le-u.le);let s=0,a=0;const i=[];for(const o of r)i.push({label:Number.isFinite(o.le)?Wa(o.le,n):`${Wa(s,n)}+`,value:Math.max(0,o.total-a)}),a=o.total,Number.isFinite(o.le)&&(s=o.le);return i}const Fa=({children:t="No data"})=>e.jsx("div",{className:"panel-empty",children:t}),tp=({panel:t,data:n})=>{if(t.kind==="stat"){const r=Zf(n),s=t.unit==="bool"?r?"good":"bad":"";return e.jsxs("div",{className:"panel-stat",children:[e.jsx("div",{className:`panel-stat-value ${s}`,children:r==null?"--":Ha(r,t.unit)}),e.jsx("div",{className:"panel-stat-label",children:t.label??t.title})]})}if(t.kind==="table")return n.series.length===0?e.jsx(Fa,{}):e.jsx("table",{className:"panel-table",children:e.jsx("tbody",{children:[...n.series].sort((r,s)=>r.name.localeCompare(s.name)).map(r=>{const s=r.points[r.points.length-1]?.[1],a=t.unit==="bool"?s?"good":"bad":"";return e.jsxs("tr",{children:[e.jsx("td",{className:"panel-table-name",children:r.name}),e.jsx("td",{className:"panel-table-trend",children:e.jsx(Gf,{points:r.points,domain:t.unit==="bool"?[0,1]:void 0,color:a==="bad"?"var(--trend-bad)":"var(--trend-ok)"})}),e.jsx("td",{className:`panel-table-value ${a}`,children:s==null?"n/a":Ha(s,t.unit)})]},r.name)})})});if(t.kind==="histogram"){const r=ep(n,t.unit);return r.every(s=>s.value===0)?e.jsx(Fa,{}):e.jsx($f,{bars:r})}return e.jsx(Qf,{series:Jf(n),unit:t.unit,kind:t.kind==="stacked"?"stacked":t.kind==="area"?"area":"line"})},Ro=({panel:t,data:n,loading:r})=>{const s=t.kind!=="stat";return e.jsxs("div",{className:`metrics-panel kind-${t.kind}`,"data-tooltip":s?void 0:t.description,children:[s&&e.jsx("div",{className:"panel-header","data-tooltip":t.description,children:e.jsx("span",{className:"panel-title",children:t.title})}),e.jsx("div",{className:"panel-body",children:r&&!n?e.jsx("div",{className:"panel-empty",children:e.jsx(xe,{size:"small"})}):n?.error?e.jsxs("div",{className:"panel-error",title:n.error,children:[e.jsx(Oa,{}),e.jsx("span",{children:n.error})]}):n?e.jsx(tp,{panel:t,data:n}):e.jsx(Fa,{})})]})},rp=[te.MetricsPlayers,te.MetricsServer,te.MetricsPlugins,te.MetricsHost],No=[{label:"1h",seconds:3600},{label:"6h",seconds:6*3600},{label:"24h",seconds:86400},{label:"7d",seconds:7*86400},{label:"15d",seconds:15*86400}],Uu="omeggaMetricsHidden";function np(){try{const t=localStorage.getItem(Uu);return t?JSON.parse(t):{}}catch{return{}}}const sp=()=>{const t=Od(...rp),[,n]=st(),[,r]=Le("/metrics/:view?"),[s,a]=C.useState(No[2].seconds),[i,o]=C.useState(np),[u,v]=C.useState(!1),x=Y.metrics.info.useQuery(void 0,{enabled:t}),_=Y.metrics.health.useQuery(void 0,{enabled:t,refetchInterval:3e4}),b=C.useMemo(()=>x.data?.dashboards??[],[x.data]),j=C.useMemo(()=>b.find(g=>g.id===r?.view)??b[0]??null,[b,r?.view]);C.useEffect(()=>{localStorage.setItem(Uu,JSON.stringify(i))},[i]);const P=C.useMemo(()=>{const g=(x.data?.retentionDays??15)*86400;return No.filter(f=>f.seconds<=g)},[x.data?.retentionDays]),w=Y.metrics.dashboard.useQuery({id:j?.id??"",range:s},{enabled:t&&!!j&&(_.data?.ok??!1),refetchInterval:15e3,placeholderData:yd}),m=C.useMemo(()=>{const g=new Map;for(const f of w.data?.panels??[])g.set(f.id,f);return g},[w.data]),l=w.isLoading||w.isPlaceholderData,c=i[j?.id??""]??[],d=g=>{if(!j)return;const f=c.includes(g)?c.filter(S=>S!==g):[...c,g];o({...i,[j.id]:f})},h=(j?.panels??[]).filter(g=>!c.includes(g.id)),y=h.filter(g=>g.kind==="stat"),p=h.filter(g=>g.kind!=="stat");return t?e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Metrics",children:j&&e.jsxs("div",{className:"widgets-container metrics-panel-list",children:[e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":"Choose which panels this dashboard shows",onClick:()=>v(!u),children:[e.jsx(uu,{}),"Panels"]}),e.jsx(Ve,{visible:u,children:j.panels.map(g=>{const f=c.includes(g.id);return e.jsxs("div",{className:"widget-item",children:[e.jsx("div",{className:"name",children:g.title}),e.jsx(Ae,{value:!f,tooltip:f?"Show panel":"Hide panel",onChange:()=>d(g.id)})]},g.id)})})]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:"generic-container metrics-container",children:[e.jsxs(we,{className:"metrics-tabs",children:[e.jsx("div",{className:"metrics-tab-group",children:b.map(g=>e.jsx(F,{normal:j?.id!==g.id,main:j?.id===g.id,boxy:!0,onClick:()=>n(`/metrics/${g.id}`),children:g.title},g.id))}),e.jsx("div",{className:"metrics-range-group",children:P.map(g=>e.jsx(F,{normal:s!==g.seconds,main:s===g.seconds,boxy:!0,"data-tooltip":`Show the last ${g.label}`,onClick:()=>a(g.seconds),children:g.label},g.label))})]}),e.jsx(Pe,{children:e.jsxs("div",{className:"metrics-content",children:[_.data&&!_.data.ok&&e.jsxs("div",{className:"metrics-banner error",children:[e.jsx(Oa,{}),e.jsxs("div",{children:[e.jsx("strong",{children:"Metrics are unavailable."})," ",_.data.configured?_.data.error??"Prometheus did not answer this request.":"No prometheus is configured for this omegga."]})]}),_.data?.ok&&!_.data.hasSeries&&e.jsxs("div",{className:"metrics-banner warn",children:[e.jsx(Oa,{}),e.jsxs("div",{children:[e.jsx("strong",{children:"Prometheus has no data for this server."})," It is reachable, but nothing is scraping omegga",x.data?.instance?` under the instance ${x.data.instance}`:"",". Check the scrape config and the metrics endpoint."]})]}),y.length>0&&e.jsx("div",{className:"metrics-stats",children:y.map(g=>e.jsx(Ro,{panel:g,data:m.get(g.id),loading:l},g.id))}),e.jsx("div",{className:"metrics-grid",children:p.map(g=>e.jsx(Ro,{panel:g,data:m.get(g.id),loading:l},g.id))}),h.length===0&&j&&e.jsx("div",{className:"metrics-banner",children:e.jsx("div",{children:"Every panel on this dashboard is hidden."})})]})})]})]})]}):null},Po={"Minute(s)":1,"Hour(s)":60,"Day(s)":1440,"Week(s)":1440*7,"Month(s)":1440*30},ap=["Permanent","Minute(s)","Hour(s)","Day(s)","Week(s)","Month(s)"],ip=()=>{const[t,n]=Le("/players/:id"),[r,s]=st(),[a,i]=C.useState(null),[o,u]=C.useState(!1),[v,x]=C.useState(""),[_,b]=C.useState(10),[j,P]=C.useState("Permanent"),[w,m]=C.useState(!1),l=ie(te.PlayerGet),c=ie(te.PlayerBan),d=ie(te.PlayerKick),h=ie(te.PlayerUnban),y=ie(te.PlayerClearBricks),{data:p,isLoading:g,refetch:f}=Y.player.get.useQuery(n?.id??"",{enabled:!!n?.id&&l});C.useEffect(()=>{!g&&!p&&n?.id&&s("/players")},[g,p,n?.id]);const S=Y.player.ban.useMutation(),N=Y.player.kick.useMutation(),O=Y.player.unban.useMutation(),R=Y.player.clearBricks.useMutation(),M=async()=>{if(!p.id)return;m(!0);const A=j==="Permanent"?-1:_*Po[j];try{await S.mutateAsync({id:p.id,duration:A,reason:v})}catch(U){console.error("Failed to ban player:",U)}i(null),f(),m(!1)},D=async()=>{if(p.id){m(!0);try{await N.mutateAsync({id:p.id,reason:v})}catch(A){console.error("Failed to kick player:",A)}i(null),f(),m(!1)}},q=async()=>{if(p.id){m(!0);try{await O.mutateAsync({id:p.id})}catch(A){console.error("Failed to unban player:",A)}f(),m(!1)}},T=async()=>{if(p.id){m(!0);try{await R.mutateAsync({id:p.id})}catch(A){console.error("Failed to clear bricks:",A)}m(!1),i(null)}},z=C.useMemo(()=>j==="Permanent"?"Never":Nd(Date.now()+Po[j]*60*1e3*_),[j,_]);return e.jsxs("div",{className:"player-inspector-container",children:[e.jsxs(we,{attached:!0,children:[e.jsx("span",{className:"inspector-title",children:p?.name||"SELECT A PLAYER"}),p&&e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>u(!o),children:[o?e.jsx(_t,{}):e.jsx(St,{}),"Actions"]}),e.jsxs(Ve,{visible:o,children:[y&&e.jsxs(F,{boxy:!0,warn:!0,disabled:w,onClick:()=>{i("clear"),u(!1)},children:[e.jsx(Ni,{}),"Clear Bricks"]}),d&&!p.isHost&&p.isOnline&&e.jsxs(F,{boxy:!0,error:!0,disabled:w,onClick:()=>{i("kick"),u(!1)},children:[e.jsx(Ei,{}),"Kick"]}),h&&p.currentBan&&e.jsxs(F,{boxy:!0,warn:!0,disabled:w,onClick:()=>{q(),u(!1)},children:[e.jsx(Kd,{}),"Unban"]}),c&&!p.isHost&&e.jsxs(F,{boxy:!0,error:!0,disabled:w,onClick:()=>{i("ban"),u(!1)},children:[e.jsx(bt,{}),"Ban"]})]})]})]}),e.jsx("div",{className:"player-inspector",children:e.jsxs("div",{className:"player-view",children:[e.jsx(xe,{active:g,size:"huge",children:"Loading Player"}),e.jsx("div",{className:"player-info",children:!g&&p&&e.jsxs(Pe,{children:[e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Profile:"})," ",e.jsx("a",{href:"https://brickadia.com/users/"+p.id,target:"_blank",children:p.name})]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Display Name:"})," ",p.displayName||"unknown"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Host:"})," ",p.isHost?"Yes":"No"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Banned:"})," ",p.currentBan&&p.currentBan.duration<=0?e.jsx("span",{children:"Permanent"}):p.currentBan?e.jsxs("span",{children:[Me(p.currentBan.remainingTime)," of"," ",Me(p.currentBan.duration)," remaining"]}):e.jsx("span",{children:"No"})]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Number of status heartbeats this player has been part of",children:"Time Played:"})," ",ru(p.heartbeats)]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Date player was last seen",children:"Last Seen:"})," ",e.jsxs("span",{"data-tooltip":new Date(p.lastSeen),children:[Me(p.seenAgo)," ago"]})]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Date player was first seen",children:"First Seen:"})," ",e.jsxs("span",{"data-tooltip":new Date(p.created),children:[Me(p.createdAgo)," ago"]})]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Number of times this player has visited the server (new visits are registered if the player joins 3 hours after last seen)",children:"Visits:"})," ",p.sessions]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Number of server instances this player has joined",children:"Server Visits:"})," ",p.instances]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Number of chat messages this player has sent",children:"Total Messages:"})," ",p.messageCount]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Bans:"})," ",p.banHistory.length]})]}),e.jsx("div",{className:"section-header","data-tooltip":"Roles this player has",children:"Roles"}),e.jsxs("div",{className:"option-list",children:[p.roles.map(A=>e.jsx("div",{className:"option-item",children:e.jsx("div",{className:"option-name",style:{color:"#"+A.color},children:A.name})},A.name)),e.jsx("div",{className:"option-item",children:e.jsx("div",{className:"option-name",style:{color:"white"},children:"Default"})})]}),e.jsx("div",{className:"section-header","data-tooltip":"Names this player has gone by historically",children:"Name History"}),e.jsxs("table",{className:"br-table name-history",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",width:"100%"},children:e.jsx("span",{children:"Name"})}),e.jsx("th",{children:"First Seen"})]})}),e.jsx("tbody",{children:p.nameHistory.map(A=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("div",{"data-tooltip":A.displayName?"Display Name":"Username",children:A.displayName||A.name}),A.displayName&&e.jsx("div",{"data-tooltip":"Username",className:"username",children:A.name})]}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(A.date),children:Me(A.ago)})]},A.date+A.name))})]}),e.jsx("div",{className:"section-header","data-tooltip":"Times this player has been banned from the server",children:"Ban History"}),e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"100%",textAlign:"left"},children:"Reason"}),e.jsx("th",{children:"Length"}),e.jsx("th",{children:"Issuer"}),e.jsx("th",{children:"Date"})]})}),e.jsxs("tbody",{children:[p.banHistory.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx("i",{children:"None"})})}),p.banHistory.map(A=>e.jsxs("tr",{children:[e.jsx("td",{className:"reason",children:A.reason}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":"Expires "+new Date(A.expires),children:0>=(A.duration??-1)?"Permanent":Me(A.duration)}),e.jsx("td",{children:e.jsx(xt,{to:"/players/"+A.bannerId,children:A.bannerName||"missing name"})}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(A.created),children:bi(A.created)})]},A.created))]})]}),e.jsx("div",{className:"section-header","data-tooltip":"Times this player has been booted from the server",children:"Kick History"}),e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{width:"100%",textAlign:"left"},children:"Reason"}),e.jsx("th",{children:"Issuer"}),e.jsx("th",{children:"Date"})]})}),e.jsxs("tbody",{children:[p.kickHistory.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,children:e.jsx("i",{children:"None"})})}),p.kickHistory.map(A=>e.jsxs("tr",{children:[e.jsx("td",{className:"reason",children:A.reason}),e.jsx("td",{children:e.jsx(xt,{to:"/players/"+A.kickerId,children:A.kickerName||"missing name"})}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(A.created),children:bi(A.created)})]},A.created))]})]})]})})]})}),e.jsxs(tt,{visible:!!a,children:[e.jsx(xe,{active:w,size:"huge",children:"Running Action..."}),e.jsxs(ct,{visible:!w,children:[e.jsx(Xe,{children:a==="ban"?"Ban Player":a==="kick"?"Kick Player":"Clear Bricks"}),(a==="kick"||a==="ban")&&e.jsxs("div",{className:`popout-inputs ${a}`,children:[e.jsx(me,{type:"text",placeholder:"Reason",value:v,onChange:x}),a==="ban"&&e.jsxs("div",{className:"ban-duration",style:{display:"flex"},children:[j!=="Permanent"&&e.jsx(me,{placeholder:"Duration",type:"number",value:_,onChange:b}),e.jsx(Ua,{options:ap,value:j,onChange:A=>P(A)})]})]}),a==="ban"&&e.jsxs(rt,{children:["This ban will expire"," ",e.jsx("span",{style:{color:"white"},children:z}),"."]}),a==="clear"&&e.jsxs(rt,{children:["Are you sure you want to clear"," ",e.jsx("span",{style:{color:"white"},children:p?.name??"??"}),"'s bricks?"]}),e.jsxs(Oe,{attached:!0,children:[a==="ban"&&e.jsxs(F,{error:!0,onClick:M,children:[e.jsx(bt,{}),"Ban"]}),a==="clear"&&e.jsxs(F,{warn:!0,onClick:T,children:[e.jsx(Ni,{}),"Clear Bricks"]}),a==="kick"&&e.jsxs(F,{error:!0,onClick:D,children:[e.jsx(Ei,{}),"Kick"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:()=>i(null),children:[e.jsx(De,{}),"Cancel"]})]})]})]})]})},op=()=>{const t=dt(te.PlayerList),[n,r]=C.useState(!1),[s,a]=st(),[i,o]=Le("/players/:id?"),{onBack:u,swipeHandlers:v,inspectorOpen:x}=Kt(!!o?.id,"/players"),_=C.useRef({page:0,search:"",sort:"lastSeen",direction:-1,filterBanned:!1}),{page:b,search:j,sort:P,direction:w,filterBanned:m}=_.current,[l,c]=C.useState({page:_.current.page,search:_.current.search,sort:_.current.sort,direction:_.current.direction,filter:""}),d=()=>{c({page:_.current.page,search:_.current.search,sort:_.current.sort,direction:_.current.direction,filter:_.current.filterBanned?"banned":""})},[h,y]=C.useState(0),p=A=>{_.current.search=A,T(),y(U=>U+1)},g=A=>{typeof A=="function"&&(A=A(_.current.page)),_.current.page=A,d()},f=A=>{typeof A=="function"&&(A=A(_.current.direction)),_.current.direction=A},S=A=>{_.current.filterBanned=A,T()},{data:N,isLoading:O,refetch:R}=Y.player.list.useQuery(l,{placeholderData:A=>A}),M=N?.players??[],D=N?.total??0,q=N?.pages??0,T=C.useMemo(()=>nu(()=>{_.current.page=0,d()},500),[]),z=A=>{A==P?f(U=>U*-1):(_.current.sort=A,f(A==="name"?1:-1)),d()};return t?e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Players",className:"players-view",onBack:u,children:e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":"Player list filters",onClick:()=>r(A=>!A),children:[e.jsx(Xd,{}),"Filters"]}),e.jsx(Ve,{visible:n,children:e.jsxs("div",{className:"widget-item","data-tooltip":"Filter by banned players",children:[e.jsxs("div",{className:"name",children:[e.jsx(bt,{}),"Banned"]}),e.jsx(Ae,{onChange:S,value:m})]})})]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:`generic-container players-container ${x?"inspector-open":""}`,...v,children:[e.jsxs("div",{className:"player-table-container",children:[e.jsxs(we,{attached:!0,children:[e.jsx(me,{type:"text",placeholder:"Search Players...",value:j,onChange:p}),e.jsx("span",{style:{flex:1}}),e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Refresh player list",onClick:()=>R(),children:e.jsx(Qt,{})})]}),e.jsxs("div",{className:"players-list",children:[e.jsx(Pe,{children:e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",width:"100%"},onClick:()=>z("name"),children:e.jsxs("span",{children:["Name",e.jsx(ke,{name:"name",sort:P,direction:w})]})}),e.jsx("th",{onClick:()=>z("heartbeats"),"data-tooltip":"Number of heartbeats the player has been part of (minutely)",children:e.jsxs("span",{children:["Played",e.jsx(ke,{name:"heartbeats",sort:P,direction:w})]})}),e.jsx("th",{onClick:()=>z("lastSeen"),"data-tooltip":"When the player was last seen",children:e.jsxs("span",{children:["Seen",e.jsx(ke,{name:"lastSeen",sort:P,direction:w})]})}),e.jsx("th",{onClick:()=>z("created"),"data-tooltip":"When the player joined",children:e.jsxs("span",{children:["Joined",e.jsx(ke,{name:"created",sort:P,direction:w})]})}),e.jsx("th",{onClick:()=>z("sessions"),"data-tooltip":"Number of Visits",children:e.jsxs("span",{className:"icon-cell",children:[e.jsx(Vd,{className:"label",size:"30"}),e.jsx(ke,{name:"sessions",sort:P,direction:w})]})}),e.jsx("th",{onClick:()=>z("messages"),"data-tooltip":"Number of chat messages sent",children:e.jsxs("span",{className:"icon-cell",children:[e.jsx(Ya,{className:"label",size:"30"}),e.jsx(ke,{name:"messages",sort:P,direction:w})]})})]})}),e.jsx("tbody",{children:M.map(A=>e.jsxs("tr",{onClick:()=>a(`/players/${A.id}`),className:A.id===o?.id?"active":"",children:[e.jsx("td",{className:`player-name ${A.ban?"ban":""}`,children:e.jsxs("div",{className:"player-name-container",children:[e.jsxs("div",{children:[e.jsx("div",{"data-tooltip":A.displayName?"Display Name":"Username",children:A.displayName||A.name}),A.displayName&&e.jsx("div",{className:"username","data-tooltip":"Username",children:A.name})]}),A.ban&&e.jsx(bt,{size:"18"})]})}),e.jsx("td",{style:{textAlign:"right"},children:ru(A.heartbeats)}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(A.lastSeen),children:Me(A.seenAgo)}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(A.created),children:Me(A.createdAgo)}),e.jsx("td",{style:{textAlign:"right"},children:A.sessions}),e.jsx("td",{style:{textAlign:"right"},children:A.messageCount})]},A.id))})]})}),e.jsxs(Oe,{className:"pagination-footer",children:[e.jsx(F,{icon:!0,normal:!0,disabled:b===0,onClick:()=>{g(0)},children:e.jsx(du,{})}),e.jsx(F,{icon:!0,normal:!0,disabled:b===0,onClick:()=>g(A=>Math.max(0,A-1)),children:e.jsx(pr,{})}),e.jsxs("div",{className:"current-page",children:[e.jsxs("div",{children:["Page ",b+1," of ",q]}),e.jsxs("div",{children:["Showing ",M.length," of ",D]})]}),e.jsx(F,{icon:!0,normal:!0,disabled:b>=q-1,onClick:()=>g(A=>Math.min(M.length-1,A+1)),children:e.jsx(iu,{})}),e.jsx(F,{icon:!0,normal:!0,disabled:b>=q-1,onClick:()=>g(M.length-1),children:e.jsx(hu,{})})]}),e.jsx(xe,{active:O,size:"huge",children:"Loading Players"})]})]}),e.jsxs(Sr,{children:[e.jsx(_e,{path:"/players/:id",component:ip}),e.jsx(_e,{children:e.jsxs("div",{className:"player-inspector-container",children:[e.jsx(we,{attached:!0,children:"SELECT A PLAYER"}),e.jsx("div",{className:"player-inspector"})]})})]})]})]})]}):null},lp=(t,n)=>{try{return JSON.stringify(t)===JSON.stringify(n)}catch{return!1}},cp=()=>{const[t,n]=Le("/plugins/:id"),[r,s]=C.useState(null),[a,i]=C.useState({}),[o,u]=C.useState(!!r?.path),[v,x]=C.useState(!1),[_,b]=C.useState({}),j=ie(te.PluginGet),P=ie(te.PluginLoad),w=ie(te.PluginUnload),m=ie(te.PluginToggle),l=ie(te.PluginConfig),c=Y.plugin.get.useQuery({shortPath:n?.id??""},{enabled:!!n?.id&&j});C.useEffect(()=>{c.data?(s(c.data),i(c.data.config??{}),u(!1)):c.isError&&u(!1)},[c.data,c.isError]);const d=Y.plugin.load.useMutation(),h=Y.plugin.unload.useMutation(),y=Y.plugin.toggle.useMutation(),p=Y.plugin.config.useMutation(),g=async()=>{n?.id&&(x(!0),await d.mutateAsync({shortPath:n.id}),await c.refetch(),x(!1))},f=async()=>{n?.id&&(x(!0),await h.mutateAsync({shortPath:n.id}),await c.refetch(),x(!1))},S=async()=>{if(!n?.id)return;x(!0),await h.mutateAsync({shortPath:n.id})&&await d.mutateAsync({shortPath:n.id}),await c.refetch(),x(!1)},N=async q=>{n?.id&&(x(!0),await y.mutateAsync({shortPath:n.id,enabled:q}),await c.refetch(),x(!1))},O=C.useRef(a);O.current=a;const R=C.useRef(r);R.current=r,Y.plugin.onStatus.useSubscription(void 0,{enabled:j,onError:ut,onData(q){q.shortPath===R.current?.path&&s(T=>({...T,...q}))}});const M=C.useMemo(()=>nu(async()=>{if(!n?.id||!R.current)return;const q={},T=O.current,z=R.current.path;for(const A in R.current?.config??{})R.current?.config[A]!=T[A]&&(q[A]=!0),await p.mutateAsync({shortPath:n?.id,config:T})&&(b(q),setTimeout(()=>{b({}),s(X=>X?.path===z?{...X,config:T}:X)}))},500),[n?.id]),D=(q,T)=>{!r||!a||(i(z=>({...z,[q]:T})),M())};return e.jsxs("div",{className:"plugin-view",children:[e.jsx(xe,{active:o,size:"huge",children:"Loading Plugin"}),e.jsx("div",{className:"plugin-info",children:!o&&r&&e.jsxs(Pe,{children:[e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Plugin name",children:"Name:"})," ",r.name]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Plugin creator",children:"Author:"})," ",r.documentation?.author??"unknown"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Description:"})," ",r.documentation?.description??"none"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"The folder this plugin runs in",children:"Folder:"})," ",r.path]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"The type of plugin this is",children:"Format:"})," ",r.format]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Number of objects in the plugin's storage",children:"Stored Objects:"})," ",r.objCount]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Plugin can be started",children:"Enabled:"})," ",r.isEnabled?"Yes":"No"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Plugin is running",children:"Loaded:"})," ",r.isLoaded?"Yes":"No"]})]}),e.jsx("div",{className:"section-header","data-tooltip":"Ways to configure the plugin. Changes take place the next time a plugin is loaded.",children:"Configs"}),e.jsxs("div",{className:"option-list",children:[Object.keys(r.documentation.config??{}).length===0&&e.jsx("div",{className:"option-item",children:e.jsx("i",{className:"option-name",children:"None"})}),Object.entries(r.documentation.config??{}).map(([q,T])=>e.jsx("div",{className:"option-item config",children:e.jsxs("div",{className:"option-input",children:[e.jsxs("div",{className:"option-label","data-tooltip":T.description,children:[q,e.jsxs("span",{className:`saved-note ${_[q]?"show":""}`,children:["SAVED ",e.jsx(fr,{size:"20"})]})]}),e.jsxs("div",{className:"option-value",children:[["string","password","number"].includes(T.type)&&e.jsx(me,{type:T.type==="string"?"text":T.type,disabled:!l,value:a[q],onChange:z=>D(q,z)}),T.type==="list"&&e.jsx(xd,{options:"options"in T?T.options:void 0,type:T.itemType,disabled:!l,value:a[q],onChange:z=>D(q,z)}),T.type==="players"&&e.jsx(bd,{disabled:!l,value:a[q],onChange:z=>D(q,z)}),T.type==="role"&&e.jsx(jd,{disabled:!l,value:a[q],onChange:z=>D(q,z)}),T.type==="enum"&&e.jsx(Ua,{options:T.options,disabled:!l,value:a[q],onChange:z=>D(q,z)}),T.type==="boolean"&&e.jsx(Ae,{disabled:!l,value:a[q],onChange:z=>D(q,z)}),l&&!lp(T.default,a[q])&&e.jsx(Qd,{onClick:()=>D(q,T.default),className:"reset-button","data-tooltip":"Reset to default value"})]})]})},q))]}),e.jsx("div",{className:"section-header","data-tooltip":"Ways to control the plugin",children:"Commands"}),e.jsxs("div",{className:"option-list",children:[(r.documentation.commands??[]).length===0&&e.jsx("div",{className:"option-item",children:e.jsx("i",{className:"option-name",children:"None"})}),(r.documentation.commands||[]).map(q=>e.jsxs("div",{className:"option-item",children:[e.jsx("div",{className:"option-name","data-tooltip":q.description,children:q.name}),e.jsx("div",{className:"option-args",children:(q.args||[]).map(T=>e.jsx("div",{className:`option-arg ${T.required?"required":""}`,"data-tooltip":(T.required?"(required) ":"")+T.description,children:T.name},T.name))})]},q.name))]})]})}),e.jsxs(Oe,{attached:!0,children:[P&&r?.isEnabled&&!r.isLoaded&&e.jsxs(F,{main:!0,disabled:v,"data-tooltip":"Start the plugin",onClick:()=>g(),children:[e.jsx(hr,{}),"Load"]}),P&&w&&r?.isEnabled&&r.isLoaded&&e.jsxs(F,{warn:!0,"data-tooltip":"Stop, then start the plugin",disabled:v,onClick:()=>S(),children:[e.jsx(fu,{}),"Reload"]}),e.jsx("span",{style:{flex:1}}),w&&r?.isEnabled&&r.isLoaded&&e.jsxs(F,{error:!0,disabled:v,"data-tooltip":"Stop the plugin",onClick:()=>f(),children:[e.jsx(pu,{}),"Unload"]}),m&&r&&!r?.isEnabled&&e.jsxs(F,{main:!0,"data-tooltip":"Allow the plugin to be started",disabled:v,onClick:()=>N(!0),children:[e.jsx(nt,{}),"Enable"]}),m&&r?.isEnabled&&!r.isLoaded&&e.jsxs(F,{error:!0,"data-tooltip":"Prevent the plugin from being started",disabled:v,onClick:()=>N(!1),children:[e.jsx(Ka,{}),"Disable"]})]})]})},Eo=t=>{const n=(t.isLoaded?2:0)+(t.isEnabled?1:0),r=["disabled","broken","bugged","running"][n],s=["Plugin is disabled","Plugin is enabled but not running","Plugin is running but not enabled","Plugin is running"][n],a=[Zd,eh,th,rh][n];return{...t,state:n,status:r,tooltip:s,icon:a}},up=()=>{const t=dt(te.PluginList),[n,r]=C.useState(""),[s,a]=C.useState(!1),[i,o]=C.useState([]),u=ie(te.PluginReloadAll),[v,x]=Le("/plugins/:id?"),{onBack:_,swipeHandlers:b,inspectorOpen:j}=Kt(!!x?.id,"/plugins"),P=C.useMemo(()=>i.find(y=>y.path===x?.id)?.name??"SELECT A PLUGIN",[i,x?.id]),w=Y.plugin.list.useQuery();C.useEffect(()=>{w.data&&o(w.data.map(Eo))},[w.data]);const m=w.isLoading,l=Y.plugin.reloadAll.useMutation(),c=()=>{w.refetch()},d=async()=>{a(!0),await l.mutateAsync(),a(!1),c()},h=y=>y.name.toLowerCase().includes(n.toLowerCase());return Y.plugin.onStatus.useSubscription(void 0,{enabled:t,onError:ut,onData(y){const p=Eo(y);o(g=>g.map(f=>f.path===y.shortPath?{...f,...p}:f))}}),t?e.jsxs(e.Fragment,{children:[e.jsxs(ze,{title:"Plugins",onBack:_,children:[e.jsx("span",{style:{flex:1}}),u&&e.jsxs(F,{warn:!0,disabled:s,onClick:d,"data-tooltip":"Reload all plugins, this may clear current plugin progress",children:[e.jsx(Jd,{}),"Reload Plugins"]})]}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:`generic-container plugins-container ${j?"inspector-open":""}`,...b,children:[e.jsxs("div",{className:"plugins-list-container",children:[e.jsxs(we,{children:[e.jsx(me,{type:"text",placeholder:"Search Plugins...",value:n,onChange:y=>r(y)}),e.jsx("span",{style:{flex:1}}),e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Refresh plugin list",onClick:c,children:e.jsx(Qt,{})})]}),e.jsxs("div",{className:"plugins-list",children:[e.jsx(Pe,{children:i.map(y=>h(y)&&e.jsxs(xt,{href:"/plugins/"+y.path,"data-tooltip":y.documentation?.description,className:`plugin-item ${x?.id===y.path?"selected":""}`,children:[e.jsx(y.icon,{className:y.status,"data-tooltip":y.tooltip}),y.name]},y.path))}),e.jsx(xe,{active:m,size:"huge",children:"Loading Plugins"})]})]}),e.jsxs("div",{className:"plugin-inspector-container",children:[e.jsx(we,{attached:!0,children:P}),e.jsx("div",{className:"plugin-inspector",children:e.jsx(cp,{})})]})]})]})]}):null},Te=Xt({starting:!1,started:!1,stopping:!1,loading:!0}),$u=()=>{const t=ie(te.ServerStatus),{data:n}=Y.server.started.useQuery(void 0,{enabled:t});return C.useEffect(()=>{n&&Te.set({started:n.started,starting:n.starting,stopping:n.stopping,loading:!1})},[n]),Y.server.onStatus.useSubscription(void 0,{enabled:t,onError:ut,onData(r){Te.set({started:r.started,starting:r.starting,stopping:r.stopping,loading:!1})}}),Ne(Te)},dp=()=>{Te.set({...Te.get(),loading:!0}),Yt.server.start.mutate()},hp=()=>{Te.set({...Te.get(),loading:!0}),Yt.server.stop.mutate()},fp=()=>{Te.set({...Te.get(),loading:!0}),Yt.server.restart.mutate()},pp=()=>{Te.set({...Te.get(),loading:!0}),Yt.server.update.run.mutate()};function mp(t){const n=Math.floor((Date.now()-t)/1e3);if(n<60)return"just now";const r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}const gp=()=>{const t=dt(te.ServerStatus),{started:n,stopping:r,starting:s,loading:a}=$u(),i=et(),o=ie(te.ServerStart),u=ie(te.ServerStop),v=ie(te.ServerRestart),x=ie(te.ServerUpdateRun),_=ie(te.ServerAutorestartGet),b=ie(te.ServerUpdateCheck),j=ie(te.ServerAutorestartSet),P=ie(te.WorldSave),[w,m]=C.useState(null),l=Ne(Ga),[c,d]=C.useState(l?.update?.lastCheck??null);C.useEffect(()=>{d(l?.update?.lastCheck??null)},[l?.update?.lastCheck]);const[h,y]=C.useState(!1),[p,g]=C.useState(null),[f,S]=C.useState(!1),{data:N}=Y.server.autoRestart.get.useQuery(void 0,{enabled:_});C.useEffect(()=>{N&&m(N)},[N]);const O=l?.update?.canCheck??!1,R=Y.server.update.check.useQuery(void 0,{enabled:!1}),M=C.useCallback(()=>{!O||!b||(y(!0),R.refetch().then(({data:X})=>{d(X??null),g(Date.now()),y(!1)}))},[O,b,R]),D=Y.server.autoRestart.set.useMutation(),q=C.useCallback(async()=>{if(!w)return;const X={type:"autoRestartConfig",maxUptime:Math.round(Math.max(1,Math.min(w.maxUptime,168))),maxUptimeEnabled:w.maxUptimeEnabled,emptyUptime:Math.round(Math.max(1,Math.min(w.emptyUptime,168))),emptyUptimeEnabled:w.emptyUptimeEnabled,dailyHour:Math.round(Math.max(0,Math.min(w.dailyHour,23))),dailyHourEnabled:w.dailyHourEnabled,announcementEnabled:w.announcementEnabled,playersEnabled:w.playersEnabled,saveWorld:w.saveWorld,autoUpdateEnabled:w.autoUpdateEnabled??!0,autoUpdateIntervalMins:Math.round(Math.max(10,Math.min(w.autoUpdateIntervalMins??60,1/0))),crashRestartEnabled:w.crashRestartEnabled??!0};D.mutate(X)},[w,D]),T=Y.world.save.useMutation(),z=async()=>{S(!0),await T.mutateAsync({}),S(!1)},A=Dd(q),U=X=>V=>{w&&(m(le=>({...le,[X]:V})),A.fire())};return t?e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Server",children:O&&b&&e.jsx(F,{main:!!c,normal:!c,"data-tooltip":"Check for updates",disabled:h,onClick:M,children:h?e.jsxs(e.Fragment,{children:[e.jsx(nh,{className:"spinning"}),"Checking..."]}):c===!0?e.jsxs(e.Fragment,{children:[e.jsx(sh,{}),"Update Available"]}):e.jsxs(e.Fragment,{children:[e.jsx(ah,{}),"Check for Update"]})})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:"generic-container server-container",children:[e.jsxs(we,{className:"server-status",children:[e.jsx("span",{className:"status-label",children:"Server Status: "}),e.jsx("span",{className:"status-value",children:s?"starting":r?"stopping":n?"started":"stopped"}),O&&b&&c!==null&&e.jsx("span",{className:"status-update",children:c?"Update available":`Up to date${p?` (checked ${mp(p)})`:""}`})]}),e.jsxs("div",{className:"buttons",children:[o&&e.jsxs(F,{main:!0,"data-tooltip":"Start the server",disabled:s||r||a||n,onClick:()=>i.prompt("start the server").then(X=>X&&dp()),children:[e.jsx(hr,{}),"Start"]}),u&&e.jsxs(F,{error:!0,"data-tooltip":"Stop the server",disabled:s||r||a||!n,onClick:()=>i.prompt("stop the server").then(X=>X&&hp()),children:[e.jsx(pu,{}),"Stop"]}),v&&e.jsxs(F,{warn:!0,"data-tooltip":"Reloads the server's world. Saves minigames/environment/bricks if 'Save World' is enabled below.",disabled:s||r||a,onClick:()=>i.prompt("restart the server").then(X=>X&&fp()),children:[e.jsx(fu,{}),"Restart"]}),P&&e.jsxs(F,{info:!0,"data-tooltip":"Save the current world.",disabled:s||r||a||f,onClick:z,children:[e.jsx(Vt,{}),"Save World"]}),x&&l?.isSteam&&e.jsxs(F,{normal:!c,main:c===!0,"data-tooltip":`Stop and update the server even if there are no updates available.
5
+
6
+ Does not save the world or player locations.`,disabled:s||r||a,onClick:()=>i.prompt("update the server").then(X=>X&&pp()),children:[e.jsx(ih,{}),"Update"]})]}),_&&e.jsxs(we,{attached:!0,style:{marginTop:8},children:["Auto Restart",e.jsx(Ad,{show:A.status===qd.Waiting})]}),_&&w&&e.jsxs("div",{className:"inputs-list",children:[e.jsxs("div",{className:"inputs-item","data-tooltip":"When enabled, automatically restarts the server if the game engine crashes",children:[e.jsx("label",{children:"Restart on Crash"}),e.jsx("div",{className:"inputs",children:e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.crashRestartEnabled??!0,onChange:U("crashRestartEnabled")})})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"When enabled on servers setup with SteamCMD, automatically updates the server when a new version is available",children:[e.jsxs("label",{children:["Auto Update",O?"":" (SteamCMD Only)"]}),e.jsxs("div",{className:"inputs",children:[e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.autoUpdateEnabled,onChange:U("autoUpdateEnabled")}),e.jsx(me,{disabled:!j,type:"number",placeholder:"Minutes",tooltip:"Interval in minutes to check for updates (min 10)",value:w.autoUpdateIntervalMins,onChange:U("autoUpdateIntervalMins")})]})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"How many hours before restarting regardless of online players",children:[e.jsx("label",{children:"Max Server Uptime (Hours)"}),e.jsxs("div",{className:"inputs",children:[e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.maxUptimeEnabled,onChange:U("maxUptimeEnabled")}),e.jsx(me,{disabled:!j,type:"number",placeholder:"Hours",tooltip:"Uptime Hours",value:w.maxUptime,onChange:U("maxUptime")})]})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"How many hours before restarting when no players are online",children:[e.jsx("label",{children:"Empty Server Lifetime (Hours)"}),e.jsxs("div",{className:"inputs",children:[e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.emptyUptimeEnabled,onChange:U("emptyUptimeEnabled")}),e.jsx(me,{disabled:!j,type:"number",placeholder:"Hours",tooltip:"Uptime Hours",value:w.emptyUptime,onChange:U("emptyUptime")})]})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"Restart every day at a certain hour",children:[e.jsx("label",{children:"Daily at a Specific Hour"}),e.jsxs("div",{className:"inputs",children:[e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.dailyHourEnabled,onChange:U("dailyHourEnabled")}),e.jsx(me,{disabled:!j,type:"number",placeholder:"Hour",tooltip:"Hour (0 = 12am, 13 = 1pm)",value:w.dailyHour,onChange:U("dailyHour")})]})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"When enabled, announces auto restart",children:[e.jsx("label",{children:"Restart Announcement"}),e.jsx("div",{className:"inputs",children:e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.announcementEnabled,onChange:U("announcementEnabled")})})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"When enabled, reconnects players at their previous positions",children:[e.jsx("label",{children:"Reload Players"}),e.jsx("div",{className:"inputs",children:e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.playersEnabled,onChange:U("playersEnabled")})})]}),e.jsxs("div",{className:"inputs-item","data-tooltip":"When enabled, saves the current world. The default world will be loaded on restart",children:[e.jsx("label",{children:"Save World"}),e.jsx("div",{className:"inputs",children:e.jsx(Ae,{disabled:!j,tooltip:"Enabled",value:w.saveWorld??!0,onChange:U("saveWorld")})})]})]}),i.children]})]})]}):null},vp=()=>{const t=ie(te.RoleList),n=ie(te.RoleDefaultPermissions),r=Ne(ht),s=Y.role.defaultPermissions.get.useQuery(void 0,{enabled:t}),a=Y.role.list.useQuery(void 0,{enabled:n&&!r?.isOwner}),i=Y.role.defaultPermissions.set.useMutation(),o=C.useMemo(()=>{if(r?.isOwner)return;if(!a.data)return Ke({root:"off",domains:{},scopes:{}});const m=r?.roles??[],l=a.data.filter(c=>m.includes(c.id)).map(c=>c.permissions);return l.length===0?Ke({root:"off",domains:{},scopes:{}}):Ke(_u(...l))},[r,a.data]),[u,v]=C.useState(null),[x,_]=C.useState(!1),[b,j]=C.useState("");C.useEffect(()=>{s.data&&v({root:s.data.root??"off",domains:s.data.domains??{},scopes:s.data.scopes??{}})},[s.data]);const P=C.useMemo(()=>!u||!s.data?!1:JSON.stringify(u)!==JSON.stringify(s.data),[u,s.data]),w=C.useCallback(async()=>{if(u){_(!0),j("");try{const m=await i.mutateAsync(u);m?j(m):s.refetch()}catch(m){j(m?.message||"Failed to save")}_(!1)}},[u]);return e.jsxs("div",{className:"player-inspector-container",children:[e.jsxs(we,{attached:!0,children:["Default Permissions",e.jsx("span",{style:{flex:1}}),n&&e.jsxs(F,{normal:!0,disabled:x||!P,onClick:w,children:[e.jsx(Vt,{}),"Save"]})]}),e.jsx("div",{className:"player-inspector",children:e.jsxs("div",{className:"player-view",children:[e.jsx(xe,{active:s.isLoading,size:"huge",children:"Loading Defaults"}),e.jsx("div",{className:"player-info",children:u&&e.jsxs(Pe,{children:[e.jsx("div",{className:"stats",children:e.jsx("div",{className:"stat",children:"These permissions apply to all users who don't have an explicit override set."})}),b&&e.jsx("div",{className:"perm-error",children:b}),e.jsx("div",{className:"section-header",children:"Permissions"}),e.jsx(yr,{perms:u,onChange:n?v:void 0,actorScopes:o})]})})]})})]})},yp=()=>{const[t,n]=Le("/roles/:id"),[r,s]=st(),a=n?.id??"",i=ie(te.RoleEdit),o=ie(te.RoleGrantPermission),u=Ne(ht),v=Y.role.list.useQuery(),x=C.useMemo(()=>{if(u?.isOwner)return 1/0;const X=u?.roles??[];let V=-1;for(const le of v.data??[])if(X.includes(le.id)){const de=le.permissions;(de?.root==="all"||de?.domains?.role==="all"||de?.scopes?.["role.edit"]===!0)&&(V=Math.max(V,le.order))}return V},[u,v.data]),_=Y.role.get.useQuery({id:a},{enabled:!!a}),b=Y.role.update.useMutation(),j=Y.role.delete.useMutation(),P=Y.useUtils(),w=_.data,m=w?u?.isOwner||w.order<x:!1,l=i&&m,c=o&&m,d=C.useMemo(()=>{if(u?.isOwner)return;if(!v.data||!w)return Ke({root:"off",domains:{},scopes:{}});const X=u?.roles??[],V=v.data.filter(le=>X.includes(le.id)&&le.order>w.order).map(le=>le.permissions);return V.length===0?Ke({root:"off",domains:{},scopes:{}}):Ke(_u(...V))},[u,v.data,w]),[h,y]=C.useState(""),[p,g]=C.useState(""),[f,S]=C.useState(null),[N,O]=C.useState(!1),[R,M]=C.useState(""),[D,q]=C.useState(!1);C.useEffect(()=>{w&&(y(w.name),g(w.description),S(w.permissions),M(""))},[w]);const T=C.useMemo(()=>w?!!(h!==w.name||p!==w.description||f&&JSON.stringify(f)!==JSON.stringify(w.permissions)):!1,[w,h,p,f]),z=C.useCallback(async()=>{if(!(!w||!f)){O(!0),M("");try{const X={id:a};h!==w.name&&(X.name=h),p!==w.description&&(X.description=p),JSON.stringify(f)!==JSON.stringify(w.permissions)&&(X.permissions=f);const V=await b.mutateAsync(X);V?M(V):(_.refetch(),P.role.list.invalidate())}catch{M("Failed to save")}O(!1)}},[w,h,p,f,a]),A=et({title:"Delete Role"}),U=async()=>{if(q(!1),!await A.prompt(e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Delete role ",e.jsx("b",{children:w?.name}),"?"]}),e.jsx("p",{children:"This will unassign it from all users."})]})))return;const V=await j.mutateAsync({id:a});V?M(V):(P.role.list.invalidate(),s("/roles"))};return a?e.jsxs("div",{className:"player-inspector-container",children:[e.jsxs(we,{attached:!0,children:[w?.name??"Role",e.jsx("span",{style:{flex:1}}),l&&e.jsxs(F,{normal:!0,disabled:N||!T,onClick:z,children:[e.jsx(Vt,{}),"Save"]})]}),e.jsx("div",{className:`player-inspector ${l?"has-footer":""}`,children:e.jsxs("div",{className:"player-view",children:[e.jsx(xe,{active:_.isLoading,size:"huge",children:"Loading Role"}),w&&e.jsx(Pe,{children:e.jsxs("div",{className:"player-info",children:[R&&e.jsx("div",{className:"perm-error",children:R}),l?e.jsxs("div",{className:"role-inspector-stats",children:[e.jsx("label",{children:"Name"}),e.jsx(me,{type:"text",value:h,onChange:X=>y(X.slice(0,64))}),e.jsx("label",{children:"Description"}),e.jsx(au,{value:p,onChange:X=>g(X.slice(0,512)),placeholder:"No description",rows:3}),e.jsx("label",{children:"Order"}),e.jsx("span",{children:w.order})]}):e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Name:"})," ",w.name]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Description:"})," ",w.description||"No description"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{children:"Order:"})," ",w.order]})]}),e.jsx("div",{className:"section-header",children:"Permissions"}),f&&e.jsx(yr,{perms:f,onChange:c?S:void 0,actorScopes:d})]})})]})}),l&&w&&e.jsxs(Oe,{attached:!0,children:[e.jsx("span",{style:{flex:1}}),e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>q(!D),children:[D?e.jsx(St,{}):e.jsx(_t,{}),"Actions"]}),e.jsx(Ve,{visible:D,direction:"up",className:"widgets-list widgets-list-up",children:e.jsxs(F,{error:!0,onClick:U,children:[e.jsx(Pr,{}),"Delete Role"]})})]})]}),A.children]}):null},xp=()=>{const t=dt(te.RoleList),n=ie(te.RoleEdit),r=ie(te.UserList),s=Ne(ht),[a,i]=st(),[o,u]=Le("/roles/:id?"),{onBack:v,swipeHandlers:x,inspectorOpen:_}=Kt(!!u?.id,"/roles"),b=Y.role.list.useQuery(),j=Y.role.create.useMutation(),P=Y.role.reorder.useMutation(),w=Y.useUtils(),[m,l]=C.useState(!1),[c,d]=C.useState(""),[h,y]=C.useState(""),[p,g]=C.useState(""),[f,S]=C.useState(!1),[N,O]=C.useState(""),[R,M]=C.useState(!1),D=C.useMemo(()=>b.data??[],[b.data]),q=C.useMemo(()=>{if(s?.isOwner)return 1/0;const B=s?.roles??[];let oe=-1;for(const fe of D)if(B.includes(fe.id)){const G=fe.permissions;(G?.root==="all"||G?.domains?.role==="all"||G?.scopes?.["role.edit"]===!0)&&(oe=Math.max(oe,fe.order))}return oe},[s,D]),T=n&&q>0,[z,A]=C.useState([]),U=C.useMemo(()=>{let B=D;if(z.length>0&&(B=z.map(oe=>D.find(fe=>fe.id===oe)).filter(Boolean)),N){const oe=N.toLowerCase();B=B.filter(fe=>fe.name.toLowerCase().includes(oe)||fe.description.toLowerCase().includes(oe))}return B},[D,z,N]),X=T&&R&&!N,V=B=>{A(B)},le=async()=>{if(z.length===0)return;const B=z.filter(oe=>{const fe=D.find(G=>G.id===oe);return fe&&fe.order<q});B.length!==0&&(await P.mutateAsync({orderedIds:B}),A([]),w.role.invalidate())},de=()=>{l(!0),d(""),y(""),g("")},Q=()=>{l(!1),d(""),y(""),g("")},he=async()=>{if(g(""),!!c.trim()){S(!0);try{const B=await j.mutateAsync({name:c.trim(),description:h.trim()});if(S(!1),typeof B=="string"){g(B);return}Q(),b.refetch(),B?.id&&i(`/roles/${B.id}`)}catch{S(!1),g("Failed to create role")}}};return t?e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Roles",onBack:v,children:n&&e.jsxs(F,{main:!0,boxy:!0,onClick:de,children:[e.jsx(nt,{}),"Create Role"]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:`generic-container players-container ${_?"inspector-open":""}`,...x,children:[e.jsxs("div",{className:"player-table-container",children:[r&&e.jsxs(we,{attached:!0,children:[e.jsxs(F,{normal:!0,boxy:!0,className:"tab-button",onClick:()=>i("/users"),children:[e.jsx(mu,{}),"Users"]}),e.jsxs(F,{main:!0,boxy:!0,className:"tab-button active",children:[e.jsx(Er,{}),"Roles"]}),e.jsx("span",{style:{flex:1}})]}),e.jsxs(we,{attached:!0,children:[e.jsx(me,{type:"text",placeholder:"Search Roles...",value:N,onChange:B=>O(B)}),e.jsx("span",{style:{flex:1}}),T&&e.jsx(Ae,{value:R,onChange:M,disabled:!!N,tooltip:R?"Exit reorder mode":"Reorder roles",icon:e.jsx($r,{size:16,color:"white"})}),e.jsx(F,{icon:!0,normal:!0,style:{marginLeft:8},"data-tooltip":"Refresh role list",onClick:()=>b.refetch(),children:e.jsx(Qt,{})})]}),e.jsxs("div",{className:"players-list",children:[e.jsx(Pe,{children:e.jsxs(bh,{axis:"y",values:U.map(B=>B.id),onReorder:V,as:"table",className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[X&&e.jsx("th",{className:"no-sort",style:{width:32},children:e.jsx($r,{size:16})}),e.jsx("th",{className:"no-sort",style:{textAlign:"left",width:"40%"},children:"Name"}),e.jsx("th",{className:"no-sort",style:{textAlign:"left"},children:"Description"})]})}),e.jsx("tbody",{children:U.map(B=>{const oe=B.order>=q,fe=X&&!oe;return e.jsxs(Ph,{value:B.id,as:"tr",className:B.id===u?.id?"active":"",onClick:()=>i(`/roles/${B.id}`),onDragEnd:le,dragListener:fe,whileDrag:{zIndex:10,position:"relative"},children:[X&&e.jsx("td",{style:{cursor:fe?"grab":"default",width:32},children:e.jsx($r,{size:16,style:{opacity:oe?.25:1}})}),e.jsx("td",{style:{fontWeight:"bold"},children:B.name}),e.jsx("td",{className:"muted-text",children:B.description})]},B.id)})}),e.jsx("tfoot",{children:e.jsxs("tr",{className:u?.id==="default"?"active":"",onClick:()=>i("/roles/default"),children:[X&&e.jsx("td",{style:{width:32}}),e.jsx("td",{style:{fontWeight:"bold"},children:"Everyone"}),e.jsx("td",{className:"muted-text",children:"Base permissions for all users"})]})})]})}),e.jsx(xe,{active:b.isLoading,size:"huge",children:"Loading Roles"})]})]}),e.jsxs(Sr,{children:[e.jsx(_e,{path:"/roles/default",component:vp}),e.jsx(_e,{path:"/roles/:id",component:yp}),e.jsx(_e,{children:e.jsxs("div",{className:"player-inspector-container",children:[e.jsx(we,{attached:!0,children:"SELECT A ROLE"}),e.jsx("div",{className:"player-inspector"})]})})]}),e.jsx(tu,{children:m&&e.jsxs(tt,{visible:!0,children:[e.jsx(xe,{active:f,size:"huge",children:"Creating"}),e.jsxs(ct,{visible:!f,children:[e.jsx(Xe,{children:"Create New Role"}),e.jsxs(rt,{children:[e.jsx("p",{children:"Create a new role with a name and optional description."}),p&&e.jsxs("p",{style:{color:"red"},children:["Error: ",p]})]}),e.jsxs("div",{className:"popout-inputs",children:[e.jsx(me,{placeholder:"Role name",type:"text",value:c,onChange:B=>d(B.slice(0,64))}),e.jsx(au,{placeholder:"Description (optional)",value:h,onChange:B=>y(B.slice(0,512)),rows:3}),c.length>=64&&e.jsx("p",{style:{color:"orange",fontSize:13},children:"Name is at the 64 character limit"}),h.length>=512&&e.jsx("p",{style:{color:"orange",fontSize:13},children:"Description is at the 512 character limit"})]}),e.jsxs(Oe,{children:[e.jsxs(F,{main:!0,disabled:!c.trim()||c.trim().length>64||h.length>512,onClick:he,children:[e.jsx(nt,{}),"Create"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:Q,children:[e.jsx(De,{}),"Cancel"]})]})]})]})})]})]})]}):null},bp="Enable Users",jp="Add User",wp=()=>{const t=dt(te.UserList),n=Ne(Ga)?.userless,r=Ne(ht),s=ie(te.UserCreate),a=ie(te.RoleList),i=Y.role.list.useQuery(void 0,{enabled:a}),o=C.useMemo(()=>{const H={};for(const ee of i.data??[])H[ee.id]=ee;return H},[i.data]),[u,v]=C.useState(0),[x,_]=C.useState(0),[b,j]=C.useState(!0),[P,w]=C.useState([]),[m,l]=C.useState(""),[c,d]=C.useState(""),[h,y]=C.useState(""),[p,g]=C.useState(""),[f,S]=C.useState(""),[N,O]=C.useState(!1),[R,M]=C.useState(!1),[D,q]=C.useState(!1),[T,z]=st(),[A,U]=Le("/users/:id?"),{onBack:X,swipeHandlers:V,inspectorOpen:le}=Kt(!!U?.id,"/users"),de=Y.useUtils(),Q=Y.user.create.useMutation(),[he,B]=C.useState(!1),oe=()=>{B(!1),M(!0),O(!1),y(""),d("")},fe=()=>{B(!1),O(!0),M(!1),y(""),d("")},G=C.useRef({page:0,sort:"lastOnline",direction:-1}),{page:ne,sort:ce,direction:E}=G.current,k=H=>{typeof H=="function"&&(H=H(G.current.page)),G.current.page=H,W()},I=H=>{typeof H=="function"&&(H=H(G.current.direction)),G.current.direction=H},W=async()=>{j(!0);const{page:H,sort:ee,direction:be}=G.current,{users:Ce,total:Re,pages:Ee}=await de.user.list.fetch({page:H,search:"",sort:ee,direction:be});v(Ee),_(Re),w(Ce),j(!1)},J=C.useRef(W);J.current=W;const K=Ne(Na);C.useEffect(()=>{t&&W()},[K,t]);const Z=H=>{H==ce?I(ee=>ee*-1):(G.current.sort=H,I(H==="name"?1:-1)),W()},re=C.useMemo(()=>{if(!m)return P;const H=m.toLowerCase();return P.filter(ee=>(ee.username||"Admin").toLowerCase().includes(H))},[P,m]),ae=()=>{O(!1),M(!1),y(""),d(""),g(""),S("")},pe=async()=>{if(d(""),p!==f)return;q(!0);let H="";try{if(H=await Q.mutateAsync({username:h,password:p}),q(!1),!H){if(R)Pd();else{const ee=h;ae(),await W(),z(`/users/${ee}`)}return}}catch(ee){console.error("error setting user credentials",ee)}d(H)},Se=C.useMemo(()=>h.match(/^\w{0,32}$/)&&h.length!==0&&p.length!==0,[h,p]);if(!t)return null;const L=n||!n&&s;return e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Users",onBack:X,children:L&&e.jsxs("div",{className:"widgets-container",children:[e.jsxs(F,{normal:!0,boxy:!0,onClick:()=>B(!he),children:[he?e.jsx(_t,{}):e.jsx(St,{}),"Actions"]}),e.jsxs(Ve,{visible:he,children:[n&&e.jsxs(F,{info:!0,onClick:oe,children:[e.jsx(ka,{}),bp]}),!n&&s&&e.jsxs(F,{main:!0,onClick:fe,children:[e.jsx(Pi,{}),jp]})]})]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:`generic-container players-container ${le?"inspector-open":""}`,...V,children:[e.jsxs("div",{className:"player-table-container",children:[a&&e.jsxs(we,{attached:!0,children:[e.jsxs(F,{main:!0,boxy:!0,className:"tab-button active",children:[e.jsx(mu,{}),"Users"]}),e.jsxs(F,{normal:!0,boxy:!0,className:"tab-button",onClick:()=>z("/roles"),children:[e.jsx(Er,{}),"Roles"]}),e.jsx("span",{style:{flex:1}})]}),e.jsxs(we,{attached:!0,children:[e.jsx(me,{type:"text",placeholder:"Search Users...",value:m,onChange:H=>l(H)}),e.jsx("span",{style:{flex:1}}),e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Refresh user list",onClick:W,children:e.jsx(Qt,{})})]}),e.jsxs("div",{className:"players-list",children:[e.jsx(Pe,{children:e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",width:"100%"},onClick:()=>Z("username"),children:e.jsxs("span",{children:["Username",e.jsx(ke,{name:"username",sort:ce,direction:E})]})}),e.jsx("th",{onClick:()=>Z("lastOnline"),"data-tooltip":"When the user was last active",children:e.jsxs("span",{children:["Active",e.jsx(ke,{name:"lastOnline",sort:ce,direction:E})]})}),e.jsx("th",{onClick:()=>Z("created"),"data-tooltip":"When the user joined",children:e.jsxs("span",{children:["Joined",e.jsx(ke,{name:"created",sort:ce,direction:E})]})})]})}),e.jsx("tbody",{children:re.map(H=>e.jsxs("tr",{onClick:()=>z(`/users/${H.username}`),className:H.username===U?.id?"active":"",children:[e.jsxs("td",{children:[e.jsxs("div",{children:[H.isBanned&&e.jsxs("span",{className:"ban",children:[e.jsx(bt,{size:14})," "]}),H.username||"Admin"," ",(H.username||"Admin")===(r?.username||"Admin")&&e.jsx("span",{style:{fontSize:12},children:"(You)"})]}),H.roles?.length>0&&e.jsx("div",{className:"muted-text",style:{fontSize:12},children:H.roles.map(ee=>o[ee]).filter(Boolean).sort((ee,be)=>ee.order-be.order).map(ee=>ee.name).join(", ")})]}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":H.lastOnline?new Date(H.lastOnline):"Never",children:H.lastOnline?Me(H.seenAgo):"Never"}),e.jsx("td",{style:{textAlign:"right"},"data-tooltip":new Date(H.created),children:Me(H.createdAgo)})]},H.username))})]})}),e.jsxs(Oe,{className:"pagination-footer",attached:!0,children:[e.jsx(F,{icon:!0,normal:!0,disabled:ne===0,onClick:()=>k(0),children:e.jsx(du,{})}),e.jsx(F,{icon:!0,normal:!0,disabled:ne===0,onClick:()=>k(H=>Math.max(0,H-1)),children:e.jsx(pr,{})}),e.jsxs("div",{className:"current-page",children:[e.jsxs("div",{children:["Page ",ne+1," of ",u]}),e.jsxs("div",{children:["Showing ",re.length," of ",x]})]}),e.jsx(F,{icon:!0,normal:!0,disabled:ne>=u-1,onClick:()=>k(H=>Math.min(u-1,H+1)),children:e.jsx(iu,{})}),e.jsx(F,{icon:!0,normal:!0,disabled:ne>=u-1,onClick:()=>k(u-1),children:e.jsx(hu,{})})]}),e.jsx(xe,{active:b,size:"huge",children:"Loading Users"})]})]}),e.jsxs(Sr,{children:[e.jsx(_e,{path:"/users/:id",component:Cu}),e.jsx(_e,{children:e.jsxs("div",{className:"player-inspector-container",children:[e.jsx(we,{attached:!0,children:"SELECT A USER"}),e.jsx("div",{className:"player-inspector"})]})})]}),e.jsxs(tt,{visible:N||R,children:[e.jsx(xe,{active:D,size:"huge",children:"Submitting"}),e.jsxs(ct,{visible:!D,children:[e.jsx(Xe,{children:R?"Enable Users":"Create New User"}),e.jsxs(rt,{children:[R&&e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"This will require you to enter a password when you sign in."}),e.jsx("p",{children:"This action cannot be undone."})]}),N&&e.jsx("p",{children:"Creating a new user. It's recommended to create a temporary password."}),c&&e.jsxs("p",{style:{color:"red"},children:["Error: ",c]})]}),e.jsxs("div",{className:"popout-inputs",children:[e.jsx(me,{placeholder:"username",type:"text",value:h,onChange:H=>y(H)}),e.jsx(me,{placeholder:"password",type:"password",value:p,onChange:H=>g(H)}),e.jsx(me,{placeholder:"confirm password",type:"password",value:f,onChange:H=>S(H),onSubmit:Se&&f===p?pe:void 0})]}),e.jsxs(Oe,{children:[e.jsxs(F,{main:!0,disabled:!Se||f!==p,onClick:()=>pe(),children:[e.jsx(Pi,{}),R?"Enable":"Add"]}),e.jsx("div",{style:{flex:1}}),e.jsxs(F,{normal:!0,onClick:ae,children:[e.jsx(De,{}),"Cancel"]})]})]})]})]})]})]})},vt=Xt(null),yt=Xt(null);var an,ko;function Sp(){if(ko)return an;ko=1;var t=Math.ceil,n=Math.max;function r(s,a,i,o){for(var u=-1,v=n(t((a-s)/(i||1)),0),x=Array(v);v--;)x[o?v:++u]=s,s+=i;return x}return an=r,an}var on,Mo;function ai(){if(Mo)return on;Mo=1;function t(n,r){return n===r||n!==n&&r!==r}return on=t,on}var ln,Oo;function Gu(){if(Oo)return ln;Oo=1;var t=_r(),n=Cr(),r="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(u){if(!n(u))return!1;var v=t(u);return v==s||v==a||v==r||v==i}return ln=o,ln}var cn,Do;function ii(){if(Do)return cn;Do=1;var t=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=t}return cn=n,cn}var un,Ao;function Ar(){if(Ao)return un;Ao=1;var t=Gu(),n=ii();function r(s){return s!=null&&n(s.length)&&!t(s)}return un=r,un}var dn,qo;function oi(){if(qo)return dn;qo=1;var t=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(s,a){var i=typeof s;return a=a??t,!!a&&(i=="number"||i!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<a}return dn=r,dn}var hn,To;function Yu(){if(To)return hn;To=1;var t=ai(),n=Ar(),r=oi(),s=Cr();function a(i,o,u){if(!s(u))return!1;var v=typeof o;return(v=="number"?n(u)&&r(o,u.length):v=="string"&&o in u)?t(u[o],i):!1}return hn=a,hn}var fn,Lo;function _p(){if(Lo)return fn;Lo=1;var t=Ed(),n=1/0,r=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=t(a),a===n||a===-n){var i=a<0?-1:1;return i*r}return a===a?a:0}return fn=s,fn}var pn,Io;function Cp(){if(Io)return pn;Io=1;var t=Sp(),n=Yu(),r=_p();function s(a){return function(i,o,u){return u&&typeof u!="number"&&n(i,o,u)&&(o=u=void 0),i=r(i),o===void 0?(o=i,i=0):o=r(o),u=u===void 0?i<o?1:-1:r(u),t(i,o,u,a)}}return pn=s,pn}var mn,zo;function Rp(){if(zo)return mn;zo=1;var t=Cp(),n=t();return mn=n,mn}var Np=Rp();const Ho=Xa(Np);var gn,Wo;function Ku(){if(Wo)return gn;Wo=1;function t(n,r){for(var s=-1,a=r.length,i=n.length;++s<a;)n[i+s]=r[s];return n}return gn=t,gn}var vn,Fo;function Pp(){if(Fo)return vn;Fo=1;var t=_r(),n=Rr(),r="[object Arguments]";function s(a){return n(a)&&t(a)==r}return vn=s,vn}var yn,Bo;function li(){if(Bo)return yn;Bo=1;var t=Pp(),n=Rr(),r=Object.prototype,s=r.hasOwnProperty,a=r.propertyIsEnumerable,i=t((function(){return arguments})())?t:function(o){return n(o)&&s.call(o,"callee")&&!a.call(o,"callee")};return yn=i,yn}var xn,Uo;function Ue(){if(Uo)return xn;Uo=1;var t=Array.isArray;return xn=t,xn}var bn,$o;function Ep(){if($o)return bn;$o=1;var t=$a(),n=li(),r=Ue(),s=t?t.isConcatSpreadable:void 0;function a(i){return r(i)||n(i)||!!(s&&i&&i[s])}return bn=a,bn}var jn,Go;function kp(){if(Go)return jn;Go=1;var t=Ku(),n=Ep();function r(s,a,i,o,u){var v=-1,x=s.length;for(i||(i=n),u||(u=[]);++v<x;){var _=s[v];a>0&&i(_)?a>1?r(_,a-1,i,o,u):t(u,_):o||(u[u.length]=_)}return u}return jn=r,jn}var wn,Yo;function Xu(){if(Yo)return wn;Yo=1;function t(n,r){for(var s=-1,a=n==null?0:n.length,i=Array(a);++s<a;)i[s]=r(n[s],s,n);return i}return wn=t,wn}var Sn,Ko;function ci(){if(Ko)return Sn;Ko=1;var t=Ue(),n=Nr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(i,o){if(t(i))return!1;var u=typeof i;return u=="number"||u=="symbol"||u=="boolean"||i==null||n(i)?!0:s.test(i)||!r.test(i)||o!=null&&i in Object(o)}return Sn=a,Sn}var _n,Xo;function Mp(){if(Xo)return _n;Xo=1;var t=at(),n=t["__core-js_shared__"];return _n=n,_n}var Cn,Vo;function Op(){if(Vo)return Cn;Vo=1;var t=Mp(),n=(function(){var s=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function r(s){return!!n&&n in s}return Cn=r,Cn}var Rn,Qo;function Vu(){if(Qo)return Rn;Qo=1;var t=Function.prototype,n=t.toString;function r(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Rn=r,Rn}var Nn,Jo;function Dp(){if(Jo)return Nn;Jo=1;var t=Gu(),n=Op(),r=Cr(),s=Vu(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,u=Object.prototype,v=o.toString,x=u.hasOwnProperty,_=RegExp("^"+v.call(x).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function b(j){if(!r(j)||n(j))return!1;var P=t(j)?_:i;return P.test(s(j))}return Nn=b,Nn}var Pn,Zo;function Ap(){if(Zo)return Pn;Zo=1;function t(n,r){return n?.[r]}return Pn=t,Pn}var En,el;function ft(){if(el)return En;el=1;var t=Dp(),n=Ap();function r(s,a){var i=n(s,a);return t(i)?i:void 0}return En=r,En}var kn,tl;function qr(){if(tl)return kn;tl=1;var t=ft(),n=t(Object,"create");return kn=n,kn}var Mn,rl;function qp(){if(rl)return Mn;rl=1;var t=qr();function n(){this.__data__=t?t(null):{},this.size=0}return Mn=n,Mn}var On,nl;function Tp(){if(nl)return On;nl=1;function t(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return On=t,On}var Dn,sl;function Lp(){if(sl)return Dn;sl=1;var t=qr(),n="__lodash_hash_undefined__",r=Object.prototype,s=r.hasOwnProperty;function a(i){var o=this.__data__;if(t){var u=o[i];return u===n?void 0:u}return s.call(o,i)?o[i]:void 0}return Dn=a,Dn}var An,al;function Ip(){if(al)return An;al=1;var t=qr(),n=Object.prototype,r=n.hasOwnProperty;function s(a){var i=this.__data__;return t?i[a]!==void 0:r.call(i,a)}return An=s,An}var qn,il;function zp(){if(il)return qn;il=1;var t=qr(),n="__lodash_hash_undefined__";function r(s,a){var i=this.__data__;return this.size+=this.has(s)?0:1,i[s]=t&&a===void 0?n:a,this}return qn=r,qn}var Tn,ol;function Hp(){if(ol)return Tn;ol=1;var t=qp(),n=Tp(),r=Lp(),s=Ip(),a=zp();function i(o){var u=-1,v=o==null?0:o.length;for(this.clear();++u<v;){var x=o[u];this.set(x[0],x[1])}}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=r,i.prototype.has=s,i.prototype.set=a,Tn=i,Tn}var Ln,ll;function Wp(){if(ll)return Ln;ll=1;function t(){this.__data__=[],this.size=0}return Ln=t,Ln}var In,cl;function Tr(){if(cl)return In;cl=1;var t=ai();function n(r,s){for(var a=r.length;a--;)if(t(r[a][0],s))return a;return-1}return In=n,In}var zn,ul;function Fp(){if(ul)return zn;ul=1;var t=Tr(),n=Array.prototype,r=n.splice;function s(a){var i=this.__data__,o=t(i,a);if(o<0)return!1;var u=i.length-1;return o==u?i.pop():r.call(i,o,1),--this.size,!0}return zn=s,zn}var Hn,dl;function Bp(){if(dl)return Hn;dl=1;var t=Tr();function n(r){var s=this.__data__,a=t(s,r);return a<0?void 0:s[a][1]}return Hn=n,Hn}var Wn,hl;function Up(){if(hl)return Wn;hl=1;var t=Tr();function n(r){return t(this.__data__,r)>-1}return Wn=n,Wn}var Fn,fl;function $p(){if(fl)return Fn;fl=1;var t=Tr();function n(r,s){var a=this.__data__,i=t(a,r);return i<0?(++this.size,a.push([r,s])):a[i][1]=s,this}return Fn=n,Fn}var Bn,pl;function Lr(){if(pl)return Bn;pl=1;var t=Wp(),n=Fp(),r=Bp(),s=Up(),a=$p();function i(o){var u=-1,v=o==null?0:o.length;for(this.clear();++u<v;){var x=o[u];this.set(x[0],x[1])}}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=r,i.prototype.has=s,i.prototype.set=a,Bn=i,Bn}var Un,ml;function ui(){if(ml)return Un;ml=1;var t=ft(),n=at(),r=t(n,"Map");return Un=r,Un}var $n,gl;function Gp(){if(gl)return $n;gl=1;var t=Hp(),n=Lr(),r=ui();function s(){this.size=0,this.__data__={hash:new t,map:new(r||n),string:new t}}return $n=s,$n}var Gn,vl;function Yp(){if(vl)return Gn;vl=1;function t(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Gn=t,Gn}var Yn,yl;function Ir(){if(yl)return Yn;yl=1;var t=Yp();function n(r,s){var a=r.__data__;return t(s)?a[typeof s=="string"?"string":"hash"]:a.map}return Yn=n,Yn}var Kn,xl;function Kp(){if(xl)return Kn;xl=1;var t=Ir();function n(r){var s=t(this,r).delete(r);return this.size-=s?1:0,s}return Kn=n,Kn}var Xn,bl;function Xp(){if(bl)return Xn;bl=1;var t=Ir();function n(r){return t(this,r).get(r)}return Xn=n,Xn}var Vn,jl;function Vp(){if(jl)return Vn;jl=1;var t=Ir();function n(r){return t(this,r).has(r)}return Vn=n,Vn}var Qn,wl;function Qp(){if(wl)return Qn;wl=1;var t=Ir();function n(r,s){var a=t(this,r),i=a.size;return a.set(r,s),this.size+=a.size==i?0:1,this}return Qn=n,Qn}var Jn,Sl;function di(){if(Sl)return Jn;Sl=1;var t=Gp(),n=Kp(),r=Xp(),s=Vp(),a=Qp();function i(o){var u=-1,v=o==null?0:o.length;for(this.clear();++u<v;){var x=o[u];this.set(x[0],x[1])}}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=r,i.prototype.has=s,i.prototype.set=a,Jn=i,Jn}var Zn,_l;function Jp(){if(_l)return Zn;_l=1;var t=di(),n="Expected a function";function r(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(n);var i=function(){var o=arguments,u=a?a.apply(this,o):o[0],v=i.cache;if(v.has(u))return v.get(u);var x=s.apply(this,o);return i.cache=v.set(u,x)||v,x};return i.cache=new(r.Cache||t),i}return r.Cache=t,Zn=r,Zn}var es,Cl;function Zp(){if(Cl)return es;Cl=1;var t=Jp(),n=500;function r(s){var a=t(s,function(o){return i.size===n&&i.clear(),o}),i=a.cache;return a}return es=r,es}var ts,Rl;function em(){if(Rl)return ts;Rl=1;var t=Zp(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,s=t(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(n,function(o,u,v,x){i.push(v?x.replace(r,"$1"):u||o)}),i});return ts=s,ts}var rs,Nl;function tm(){if(Nl)return rs;Nl=1;var t=$a(),n=Xu(),r=Ue(),s=Nr(),a=t?t.prototype:void 0,i=a?a.toString:void 0;function o(u){if(typeof u=="string")return u;if(r(u))return n(u,o)+"";if(s(u))return i?i.call(u):"";var v=u+"";return v=="0"&&1/u==-1/0?"-0":v}return rs=o,rs}var ns,Pl;function rm(){if(Pl)return ns;Pl=1;var t=tm();function n(r){return r==null?"":t(r)}return ns=n,ns}var ss,El;function Qu(){if(El)return ss;El=1;var t=Ue(),n=ci(),r=em(),s=rm();function a(i,o){return t(i)?i:n(i,o)?[i]:r(s(i))}return ss=a,ss}var as,kl;function zr(){if(kl)return as;kl=1;var t=Nr();function n(r){if(typeof r=="string"||t(r))return r;var s=r+"";return s=="0"&&1/r==-1/0?"-0":s}return as=n,as}var is,Ml;function hi(){if(Ml)return is;Ml=1;var t=Qu(),n=zr();function r(s,a){a=t(a,s);for(var i=0,o=a.length;s!=null&&i<o;)s=s[n(a[i++])];return i&&i==o?s:void 0}return is=r,is}var os,Ol;function nm(){if(Ol)return os;Ol=1;var t=Lr();function n(){this.__data__=new t,this.size=0}return os=n,os}var ls,Dl;function sm(){if(Dl)return ls;Dl=1;function t(n){var r=this.__data__,s=r.delete(n);return this.size=r.size,s}return ls=t,ls}var cs,Al;function am(){if(Al)return cs;Al=1;function t(n){return this.__data__.get(n)}return cs=t,cs}var us,ql;function im(){if(ql)return us;ql=1;function t(n){return this.__data__.has(n)}return us=t,us}var ds,Tl;function om(){if(Tl)return ds;Tl=1;var t=Lr(),n=ui(),r=di(),s=200;function a(i,o){var u=this.__data__;if(u instanceof t){var v=u.__data__;if(!n||v.length<s-1)return v.push([i,o]),this.size=++u.size,this;u=this.__data__=new r(v)}return u.set(i,o),this.size=u.size,this}return ds=a,ds}var hs,Ll;function Ju(){if(Ll)return hs;Ll=1;var t=Lr(),n=nm(),r=sm(),s=am(),a=im(),i=om();function o(u){var v=this.__data__=new t(u);this.size=v.size}return o.prototype.clear=n,o.prototype.delete=r,o.prototype.get=s,o.prototype.has=a,o.prototype.set=i,hs=o,hs}var fs,Il;function lm(){if(Il)return fs;Il=1;var t="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,t),this}return fs=n,fs}var ps,zl;function cm(){if(zl)return ps;zl=1;function t(n){return this.__data__.has(n)}return ps=t,ps}var ms,Hl;function um(){if(Hl)return ms;Hl=1;var t=di(),n=lm(),r=cm();function s(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new t;++i<o;)this.add(a[i])}return s.prototype.add=s.prototype.push=n,s.prototype.has=r,ms=s,ms}var gs,Wl;function dm(){if(Wl)return gs;Wl=1;function t(n,r){for(var s=-1,a=n==null?0:n.length;++s<a;)if(r(n[s],s,n))return!0;return!1}return gs=t,gs}var vs,Fl;function hm(){if(Fl)return vs;Fl=1;function t(n,r){return n.has(r)}return vs=t,vs}var ys,Bl;function Zu(){if(Bl)return ys;Bl=1;var t=um(),n=dm(),r=hm(),s=1,a=2;function i(o,u,v,x,_,b){var j=v&s,P=o.length,w=u.length;if(P!=w&&!(j&&w>P))return!1;var m=b.get(o),l=b.get(u);if(m&&l)return m==u&&l==o;var c=-1,d=!0,h=v&a?new t:void 0;for(b.set(o,u),b.set(u,o);++c<P;){var y=o[c],p=u[c];if(x)var g=j?x(p,y,c,u,o,b):x(y,p,c,o,u,b);if(g!==void 0){if(g)continue;d=!1;break}if(h){if(!n(u,function(f,S){if(!r(h,S)&&(y===f||_(y,f,v,x,b)))return h.push(S)})){d=!1;break}}else if(!(y===p||_(y,p,v,x,b))){d=!1;break}}return b.delete(o),b.delete(u),d}return ys=i,ys}var xs,Ul;function fm(){if(Ul)return xs;Ul=1;var t=at(),n=t.Uint8Array;return xs=n,xs}var bs,$l;function pm(){if($l)return bs;$l=1;function t(n){var r=-1,s=Array(n.size);return n.forEach(function(a,i){s[++r]=[i,a]}),s}return bs=t,bs}var js,Gl;function mm(){if(Gl)return js;Gl=1;function t(n){var r=-1,s=Array(n.size);return n.forEach(function(a){s[++r]=a}),s}return js=t,js}var ws,Yl;function gm(){if(Yl)return ws;Yl=1;var t=$a(),n=fm(),r=ai(),s=Zu(),a=pm(),i=mm(),o=1,u=2,v="[object Boolean]",x="[object Date]",_="[object Error]",b="[object Map]",j="[object Number]",P="[object RegExp]",w="[object Set]",m="[object String]",l="[object Symbol]",c="[object ArrayBuffer]",d="[object DataView]",h=t?t.prototype:void 0,y=h?h.valueOf:void 0;function p(g,f,S,N,O,R,M){switch(S){case d:if(g.byteLength!=f.byteLength||g.byteOffset!=f.byteOffset)return!1;g=g.buffer,f=f.buffer;case c:return!(g.byteLength!=f.byteLength||!R(new n(g),new n(f)));case v:case x:case j:return r(+g,+f);case _:return g.name==f.name&&g.message==f.message;case P:case m:return g==f+"";case b:var D=a;case w:var q=N&o;if(D||(D=i),g.size!=f.size&&!q)return!1;var T=M.get(g);if(T)return T==f;N|=u,M.set(g,f);var z=s(D(g),D(f),N,O,R,M);return M.delete(g),z;case l:if(y)return y.call(g)==y.call(f)}return!1}return ws=p,ws}var Ss,Kl;function vm(){if(Kl)return Ss;Kl=1;var t=Ku(),n=Ue();function r(s,a,i){var o=a(s);return n(s)?o:t(o,i(s))}return Ss=r,Ss}var _s,Xl;function ym(){if(Xl)return _s;Xl=1;function t(n,r){for(var s=-1,a=n==null?0:n.length,i=0,o=[];++s<a;){var u=n[s];r(u,s,n)&&(o[i++]=u)}return o}return _s=t,_s}var Cs,Vl;function xm(){if(Vl)return Cs;Vl=1;function t(){return[]}return Cs=t,Cs}var Rs,Ql;function bm(){if(Ql)return Rs;Ql=1;var t=ym(),n=xm(),r=Object.prototype,s=r.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),t(a(o),function(u){return s.call(o,u)}))}:n;return Rs=i,Rs}var Ns,Jl;function jm(){if(Jl)return Ns;Jl=1;function t(n,r){for(var s=-1,a=Array(n);++s<n;)a[s]=r(s);return a}return Ns=t,Ns}var Ft={exports:{}},Ps,Zl;function wm(){if(Zl)return Ps;Zl=1;function t(){return!1}return Ps=t,Ps}Ft.exports;var ec;function ed(){return ec||(ec=1,(function(t,n){var r=at(),s=wm(),a=n&&!n.nodeType&&n,i=a&&!0&&t&&!t.nodeType&&t,o=i&&i.exports===a,u=o?r.Buffer:void 0,v=u?u.isBuffer:void 0,x=v||s;t.exports=x})(Ft,Ft.exports)),Ft.exports}var Es,tc;function Sm(){if(tc)return Es;tc=1;var t=_r(),n=ii(),r=Rr(),s="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",u="[object Error]",v="[object Function]",x="[object Map]",_="[object Number]",b="[object Object]",j="[object RegExp]",P="[object Set]",w="[object String]",m="[object WeakMap]",l="[object ArrayBuffer]",c="[object DataView]",d="[object Float32Array]",h="[object Float64Array]",y="[object Int8Array]",p="[object Int16Array]",g="[object Int32Array]",f="[object Uint8Array]",S="[object Uint8ClampedArray]",N="[object Uint16Array]",O="[object Uint32Array]",R={};R[d]=R[h]=R[y]=R[p]=R[g]=R[f]=R[S]=R[N]=R[O]=!0,R[s]=R[a]=R[l]=R[i]=R[c]=R[o]=R[u]=R[v]=R[x]=R[_]=R[b]=R[j]=R[P]=R[w]=R[m]=!1;function M(D){return r(D)&&n(D.length)&&!!R[t(D)]}return Es=M,Es}var ks,rc;function td(){if(rc)return ks;rc=1;function t(n){return function(r){return n(r)}}return ks=t,ks}var Bt={exports:{}};Bt.exports;var nc;function _m(){return nc||(nc=1,(function(t,n){var r=kd(),s=n&&!n.nodeType&&n,a=s&&!0&&t&&!t.nodeType&&t,i=a&&a.exports===s,o=i&&r.process,u=(function(){try{var v=a&&a.require&&a.require("util").types;return v||o&&o.binding&&o.binding("util")}catch{}})();t.exports=u})(Bt,Bt.exports)),Bt.exports}var Ms,sc;function rd(){if(sc)return Ms;sc=1;var t=Sm(),n=td(),r=_m(),s=r&&r.isTypedArray,a=s?n(s):t;return Ms=a,Ms}var Os,ac;function Cm(){if(ac)return Os;ac=1;var t=jm(),n=li(),r=Ue(),s=ed(),a=oi(),i=rd(),o=Object.prototype,u=o.hasOwnProperty;function v(x,_){var b=r(x),j=!b&&n(x),P=!b&&!j&&s(x),w=!b&&!j&&!P&&i(x),m=b||j||P||w,l=m?t(x.length,String):[],c=l.length;for(var d in x)(_||u.call(x,d))&&!(m&&(d=="length"||P&&(d=="offset"||d=="parent")||w&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||a(d,c)))&&l.push(d);return l}return Os=v,Os}var Ds,ic;function Rm(){if(ic)return Ds;ic=1;var t=Object.prototype;function n(r){var s=r&&r.constructor,a=typeof s=="function"&&s.prototype||t;return r===a}return Ds=n,Ds}var As,oc;function Nm(){if(oc)return As;oc=1;function t(n,r){return function(s){return n(r(s))}}return As=t,As}var qs,lc;function Pm(){if(lc)return qs;lc=1;var t=Nm(),n=t(Object.keys,Object);return qs=n,qs}var Ts,cc;function Em(){if(cc)return Ts;cc=1;var t=Rm(),n=Pm(),r=Object.prototype,s=r.hasOwnProperty;function a(i){if(!t(i))return n(i);var o=[];for(var u in Object(i))s.call(i,u)&&u!="constructor"&&o.push(u);return o}return Ts=a,Ts}var Ls,uc;function fi(){if(uc)return Ls;uc=1;var t=Cm(),n=Em(),r=Ar();function s(a){return r(a)?t(a):n(a)}return Ls=s,Ls}var Is,dc;function km(){if(dc)return Is;dc=1;var t=vm(),n=bm(),r=fi();function s(a){return t(a,r,n)}return Is=s,Is}var zs,hc;function Mm(){if(hc)return zs;hc=1;var t=km(),n=1,r=Object.prototype,s=r.hasOwnProperty;function a(i,o,u,v,x,_){var b=u&n,j=t(i),P=j.length,w=t(o),m=w.length;if(P!=m&&!b)return!1;for(var l=P;l--;){var c=j[l];if(!(b?c in o:s.call(o,c)))return!1}var d=_.get(i),h=_.get(o);if(d&&h)return d==o&&h==i;var y=!0;_.set(i,o),_.set(o,i);for(var p=b;++l<P;){c=j[l];var g=i[c],f=o[c];if(v)var S=b?v(f,g,c,o,i,_):v(g,f,c,i,o,_);if(!(S===void 0?g===f||x(g,f,u,v,_):S)){y=!1;break}p||(p=c=="constructor")}if(y&&!p){var N=i.constructor,O=o.constructor;N!=O&&"constructor"in i&&"constructor"in o&&!(typeof N=="function"&&N instanceof N&&typeof O=="function"&&O instanceof O)&&(y=!1)}return _.delete(i),_.delete(o),y}return zs=a,zs}var Hs,fc;function Om(){if(fc)return Hs;fc=1;var t=ft(),n=at(),r=t(n,"DataView");return Hs=r,Hs}var Ws,pc;function Dm(){if(pc)return Ws;pc=1;var t=ft(),n=at(),r=t(n,"Promise");return Ws=r,Ws}var Fs,mc;function Am(){if(mc)return Fs;mc=1;var t=ft(),n=at(),r=t(n,"Set");return Fs=r,Fs}var Bs,gc;function qm(){if(gc)return Bs;gc=1;var t=ft(),n=at(),r=t(n,"WeakMap");return Bs=r,Bs}var Us,vc;function Tm(){if(vc)return Us;vc=1;var t=Om(),n=ui(),r=Dm(),s=Am(),a=qm(),i=_r(),o=Vu(),u="[object Map]",v="[object Object]",x="[object Promise]",_="[object Set]",b="[object WeakMap]",j="[object DataView]",P=o(t),w=o(n),m=o(r),l=o(s),c=o(a),d=i;return(t&&d(new t(new ArrayBuffer(1)))!=j||n&&d(new n)!=u||r&&d(r.resolve())!=x||s&&d(new s)!=_||a&&d(new a)!=b)&&(d=function(h){var y=i(h),p=y==v?h.constructor:void 0,g=p?o(p):"";if(g)switch(g){case P:return j;case w:return u;case m:return x;case l:return _;case c:return b}return y}),Us=d,Us}var $s,yc;function Lm(){if(yc)return $s;yc=1;var t=Ju(),n=Zu(),r=gm(),s=Mm(),a=Tm(),i=Ue(),o=ed(),u=rd(),v=1,x="[object Arguments]",_="[object Array]",b="[object Object]",j=Object.prototype,P=j.hasOwnProperty;function w(m,l,c,d,h,y){var p=i(m),g=i(l),f=p?_:a(m),S=g?_:a(l);f=f==x?b:f,S=S==x?b:S;var N=f==b,O=S==b,R=f==S;if(R&&o(m)){if(!o(l))return!1;p=!0,N=!1}if(R&&!N)return y||(y=new t),p||u(m)?n(m,l,c,d,h,y):r(m,l,f,c,d,h,y);if(!(c&v)){var M=N&&P.call(m,"__wrapped__"),D=O&&P.call(l,"__wrapped__");if(M||D){var q=M?m.value():m,T=D?l.value():l;return y||(y=new t),h(q,T,c,d,y)}}return R?(y||(y=new t),s(m,l,c,d,h,y)):!1}return $s=w,$s}var Gs,xc;function nd(){if(xc)return Gs;xc=1;var t=Lm(),n=Rr();function r(s,a,i,o,u){return s===a?!0:s==null||a==null||!n(s)&&!n(a)?s!==s&&a!==a:t(s,a,i,o,r,u)}return Gs=r,Gs}var Ys,bc;function Im(){if(bc)return Ys;bc=1;var t=Ju(),n=nd(),r=1,s=2;function a(i,o,u,v){var x=u.length,_=x,b=!v;if(i==null)return!_;for(i=Object(i);x--;){var j=u[x];if(b&&j[2]?j[1]!==i[j[0]]:!(j[0]in i))return!1}for(;++x<_;){j=u[x];var P=j[0],w=i[P],m=j[1];if(b&&j[2]){if(w===void 0&&!(P in i))return!1}else{var l=new t;if(v)var c=v(w,m,P,i,o,l);if(!(c===void 0?n(m,w,r|s,v,l):c))return!1}}return!0}return Ys=a,Ys}var Ks,jc;function sd(){if(jc)return Ks;jc=1;var t=Cr();function n(r){return r===r&&!t(r)}return Ks=n,Ks}var Xs,wc;function zm(){if(wc)return Xs;wc=1;var t=sd(),n=fi();function r(s){for(var a=n(s),i=a.length;i--;){var o=a[i],u=s[o];a[i]=[o,u,t(u)]}return a}return Xs=r,Xs}var Vs,Sc;function ad(){if(Sc)return Vs;Sc=1;function t(n,r){return function(s){return s==null?!1:s[n]===r&&(r!==void 0||n in Object(s))}}return Vs=t,Vs}var Qs,_c;function Hm(){if(_c)return Qs;_c=1;var t=Im(),n=zm(),r=ad();function s(a){var i=n(a);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(o){return o===a||t(o,a,i)}}return Qs=s,Qs}var Js,Cc;function Wm(){if(Cc)return Js;Cc=1;var t=hi();function n(r,s,a){var i=r==null?void 0:t(r,s);return i===void 0?a:i}return Js=n,Js}var Zs,Rc;function Fm(){if(Rc)return Zs;Rc=1;function t(n,r){return n!=null&&r in Object(n)}return Zs=t,Zs}var ea,Nc;function Bm(){if(Nc)return ea;Nc=1;var t=Qu(),n=li(),r=Ue(),s=oi(),a=ii(),i=zr();function o(u,v,x){v=t(v,u);for(var _=-1,b=v.length,j=!1;++_<b;){var P=i(v[_]);if(!(j=u!=null&&x(u,P)))break;u=u[P]}return j||++_!=b?j:(b=u==null?0:u.length,!!b&&a(b)&&s(P,b)&&(r(u)||n(u)))}return ea=o,ea}var ta,Pc;function Um(){if(Pc)return ta;Pc=1;var t=Fm(),n=Bm();function r(s,a){return s!=null&&n(s,a,t)}return ta=r,ta}var ra,Ec;function $m(){if(Ec)return ra;Ec=1;var t=nd(),n=Wm(),r=Um(),s=ci(),a=sd(),i=ad(),o=zr(),u=1,v=2;function x(_,b){return s(_)&&a(b)?i(o(_),b):function(j){var P=n(j,_);return P===void 0&&P===b?r(j,_):t(b,P,u|v)}}return ra=x,ra}var na,kc;function Hr(){if(kc)return na;kc=1;function t(n){return n}return na=t,na}var sa,Mc;function Gm(){if(Mc)return sa;Mc=1;function t(n){return function(r){return r?.[n]}}return sa=t,sa}var aa,Oc;function Ym(){if(Oc)return aa;Oc=1;var t=hi();function n(r){return function(s){return t(s,r)}}return aa=n,aa}var ia,Dc;function Km(){if(Dc)return ia;Dc=1;var t=Gm(),n=Ym(),r=ci(),s=zr();function a(i){return r(i)?t(s(i)):n(i)}return ia=a,ia}var oa,Ac;function Xm(){if(Ac)return oa;Ac=1;var t=Hm(),n=$m(),r=Hr(),s=Ue(),a=Km();function i(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?s(o)?n(o[0],o[1]):t(o):a(o)}return oa=i,oa}var la,qc;function Vm(){if(qc)return la;qc=1;function t(n){return function(r,s,a){for(var i=-1,o=Object(r),u=a(r),v=u.length;v--;){var x=u[n?v:++i];if(s(o[x],x,o)===!1)break}return r}}return la=t,la}var ca,Tc;function Qm(){if(Tc)return ca;Tc=1;var t=Vm(),n=t();return ca=n,ca}var ua,Lc;function Jm(){if(Lc)return ua;Lc=1;var t=Qm(),n=fi();function r(s,a){return s&&t(s,a,n)}return ua=r,ua}var da,Ic;function Zm(){if(Ic)return da;Ic=1;var t=Ar();function n(r,s){return function(a,i){if(a==null)return a;if(!t(a))return r(a,i);for(var o=a.length,u=s?o:-1,v=Object(a);(s?u--:++u<o)&&i(v[u],u,v)!==!1;);return a}}return da=n,da}var ha,zc;function eg(){if(zc)return ha;zc=1;var t=Jm(),n=Zm(),r=n(t);return ha=r,ha}var fa,Hc;function tg(){if(Hc)return fa;Hc=1;var t=eg(),n=Ar();function r(s,a){var i=-1,o=n(s)?Array(s.length):[];return t(s,function(u,v,x){o[++i]=a(u,v,x)}),o}return fa=r,fa}var pa,Wc;function rg(){if(Wc)return pa;Wc=1;function t(n,r){var s=n.length;for(n.sort(r);s--;)n[s]=n[s].value;return n}return pa=t,pa}var ma,Fc;function ng(){if(Fc)return ma;Fc=1;var t=Nr();function n(r,s){if(r!==s){var a=r!==void 0,i=r===null,o=r===r,u=t(r),v=s!==void 0,x=s===null,_=s===s,b=t(s);if(!x&&!b&&!u&&r>s||u&&v&&_&&!x&&!b||i&&v&&_||!a&&_||!o)return 1;if(!i&&!u&&!b&&r<s||b&&a&&o&&!i&&!u||x&&a&&o||!v&&o||!_)return-1}return 0}return ma=n,ma}var ga,Bc;function sg(){if(Bc)return ga;Bc=1;var t=ng();function n(r,s,a){for(var i=-1,o=r.criteria,u=s.criteria,v=o.length,x=a.length;++i<v;){var _=t(o[i],u[i]);if(_){if(i>=x)return _;var b=a[i];return _*(b=="desc"?-1:1)}}return r.index-s.index}return ga=n,ga}var va,Uc;function ag(){if(Uc)return va;Uc=1;var t=Xu(),n=hi(),r=Xm(),s=tg(),a=rg(),i=td(),o=sg(),u=Hr(),v=Ue();function x(_,b,j){b.length?b=t(b,function(m){return v(m)?function(l){return n(l,m.length===1?m[0]:m)}:m}):b=[u];var P=-1;b=t(b,i(r));var w=s(_,function(m,l,c){var d=t(b,function(h){return h(m)});return{criteria:d,index:++P,value:m}});return a(w,function(m,l){return o(m,l,j)})}return va=x,va}var ya,$c;function ig(){if($c)return ya;$c=1;function t(n,r,s){switch(s.length){case 0:return n.call(r);case 1:return n.call(r,s[0]);case 2:return n.call(r,s[0],s[1]);case 3:return n.call(r,s[0],s[1],s[2])}return n.apply(r,s)}return ya=t,ya}var xa,Gc;function og(){if(Gc)return xa;Gc=1;var t=ig(),n=Math.max;function r(s,a,i){return a=n(a===void 0?s.length-1:a,0),function(){for(var o=arguments,u=-1,v=n(o.length-a,0),x=Array(v);++u<v;)x[u]=o[a+u];u=-1;for(var _=Array(a+1);++u<a;)_[u]=o[u];return _[a]=i(x),t(s,this,_)}}return xa=r,xa}var ba,Yc;function lg(){if(Yc)return ba;Yc=1;function t(n){return function(){return n}}return ba=t,ba}var ja,Kc;function cg(){if(Kc)return ja;Kc=1;var t=ft(),n=(function(){try{var r=t(Object,"defineProperty");return r({},"",{}),r}catch{}})();return ja=n,ja}var wa,Xc;function ug(){if(Xc)return wa;Xc=1;var t=lg(),n=cg(),r=Hr(),s=n?function(a,i){return n(a,"toString",{configurable:!0,enumerable:!1,value:t(i),writable:!0})}:r;return wa=s,wa}var Sa,Vc;function dg(){if(Vc)return Sa;Vc=1;var t=800,n=16,r=Date.now;function s(a){var i=0,o=0;return function(){var u=r(),v=n-(u-o);if(o=u,v>0){if(++i>=t)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return Sa=s,Sa}var _a,Qc;function hg(){if(Qc)return _a;Qc=1;var t=ug(),n=dg(),r=n(t);return _a=r,_a}var Ca,Jc;function fg(){if(Jc)return Ca;Jc=1;var t=Hr(),n=og(),r=hg();function s(a,i){return r(n(a,i,t),a+"")}return Ca=s,Ca}var Ra,Zc;function pg(){if(Zc)return Ra;Zc=1;var t=kp(),n=ag(),r=fg(),s=Yu(),a=r(function(i,o){if(i==null)return[];var u=o.length;return u>1&&s(i,o[0],o[1])?o=[]:u>2&&s(o[0],o[1],o[2])&&(o=[o[0]]),n(i,t(o,1),[])});return Ra=a,Ra}var mg=pg();const zt=Xa(mg),gg=()=>{const[t,n]=Le("/worlds/*"),r=n?.["*"],[s,a]=C.useState(!1),i=Ne(vt),o=Ne(yt),u=Ne(Te),v=ie(te.WorldRevisions),x=ie(te.WorldUse),_=ie(te.WorldLoad),[b,j]=C.useState(!1),[P,w]=C.useState(null),[m,l]=C.useState(null),c=C.useRef(r);c.current=r;const d=Y.useUtils(),h=Y.world.use.useMutation(),y=Y.world.load.useMutation(),p=et();C.useEffect(()=>{!r||!u.started||!v||(j(!0),w(null),Promise.all([d.world.revisions.fetch({world:r}),d.world.meta.fetch({world:r})]).then(([N,O])=>{c.current===r&&(w(N?.reverse()??null),l(O??null),j(!1))}))},[r,u.started]);const g=async()=>{if(!r)return;a(!0),await h.mutateAsync({world:r})&&(yt.set(r),vt.set(r)),a(!1)},f=async()=>{if(!r)return;if(a(!0),await h.mutateAsync({})){const O=await d.world.next.fetch(),R=await d.world.active.fetch();yt.set(R),vt.set(O)}a(!1)},S=async N=>{if(!r)return;a(!0);const O=await y.mutateAsync({world:r,revision:N??void 0});console.info("world loaded",O),a(!1)};return e.jsxs("div",{className:"world-view",children:[e.jsx("div",{className:"world-info",children:r&&e.jsxs(Pe,{children:[e.jsxs("div",{className:"stats",children:[e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"World name",children:"Name:"})," ",r]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"World map",children:"Map:"})," ",m?.meta.world.environment??"Unknown"]}),e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"If yes, this world will be loaded on the next server start",children:"Is Default:"})," ",o===r?"Yes":"No"]}),i!==o&&e.jsxs("div",{className:"stat",children:[e.jsx("b",{"data-tooltip":"Whether this world is configured to load next start if no other default is specified",children:"Is Fallback World:"})," ",i===r?"Yes":"No"]})]}),e.jsx("div",{className:"section-header","data-tooltip":"A list of all brick, component, or entity owners in this world.",children:"Owners"}),e.jsx("div",{className:"owners-table",children:e.jsx(vg,{meta:m})}),e.jsx("div",{className:"section-header","data-tooltip":"A list of all the revisions made to this world. Click the buttons on the right to load a specific revision.",children:"Revisions"}),e.jsxs("div",{className:"revision-list",children:[e.jsx(tt,{visible:b,children:e.jsx(xe,{active:b,size:"huge",children:"Loading World"})}),P?.length===0&&e.jsx("div",{className:"revision-item",children:e.jsx("i",{className:"revision-note",children:"Something went wrong listing the revisions"})}),P===null&&!b&&u.started&&e.jsx("div",{className:"revision-item",children:e.jsx("i",{className:"revision-note",children:v?"World might not exist":"Missing permission to view revisions"})}),P?.map(N=>e.jsxs("div",{className:"revision-item config",children:[e.jsx("div",{className:"revision-index",children:N.index}),e.jsxs("div",{className:"revision-note",children:[N.note,e.jsx("div",{className:"revision-date",children:new Date(N.date).toLocaleString()})]}),_&&e.jsx(F,{icon:!0,main:!0,disabled:s||!u.started,onClick:()=>p.prompt(e.jsxs("p",{children:["Are you sure you want to load revision ",N.index," ","of"," ",e.jsx("b",{style:{color:"white"},children:r}),"? Unsaved work will be lost."]})).then(O=>{O&&S(N.index)}),"data-tooltip":`Load revision ${N.index}`,children:e.jsx(hr,{})})]},N.index))]})]})}),e.jsxs(Oe,{attached:!0,children:[x&&o!==r&&e.jsxs(F,{normal:!0,disabled:s||!r,"data-tooltip":"Make this the default world for the server (on startup)",onClick:()=>g(),children:[e.jsx(gu,{}),"Make Default"]}),x&&o===r&&e.jsxs(F,{warn:!0,disabled:s||!r,"data-tooltip":"Remove this world as the default world for the server (on startup)",onClick:()=>f(),children:[e.jsx(vu,{}),"Clear Default"]}),e.jsx("span",{style:{flex:1}}),_&&e.jsxs(F,{main:!0,"data-tooltip":"Load this world immediately",disabled:s||!u.started||!r,onClick:()=>p.prompt(e.jsxs("p",{children:["Are you sure you want to load"," ",e.jsx("b",{style:{color:"white"},children:r}),"? Unsaved work will be lost."]})).then(N=>{N&&S()}),children:[e.jsx(hr,{}),"Load"]})]}),p.children]})},vg=({meta:t})=>{const[n,r]=st(),s=C.useMemo(()=>Object.fromEntries(t?.owners.map(_=>[_.id,_])??[]),[t]),a=C.useMemo(()=>{const _=Object.keys(s),b=zt(_,d=>s[d].display_name),j=zt(_,d=>s[d].brick_count),P=zt(_,d=>s[d].component_count),w=zt(_,d=>s[d].entity_count),m=zt(_,d=>s[d].wire_count),l=Ho(_.length).reverse(),c=Ho(_.length);return{display_name:b,brick_count:j,component_count:P,entity_count:w,wire_count:m,reverse:l,inorder:c}},[t]),[i,o]=C.useState("brick_count"),[u,v]=C.useState(-1),x=_=>{_==i?v(b=>b*-1):(o(_),v(_==="display_name"?1:-1))};return t?e.jsx(Pe,{children:e.jsxs("table",{className:"br-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:{textAlign:"left",width:"100%"},onClick:()=>x("display_name"),children:e.jsxs("span",{children:["Name",e.jsx(ke,{name:"display_name",sort:i,direction:u})]})}),e.jsx("th",{onClick:()=>x("brick_count"),children:e.jsxs("span",{children:["Bricks",e.jsx(ke,{name:"brick_count",sort:i,direction:u})]})}),e.jsx("th",{onClick:()=>x("component_count"),children:e.jsxs("span",{children:["Components",e.jsx(ke,{name:"component_count",sort:i,direction:u})]})}),e.jsx("th",{onClick:()=>x("entity_count"),children:e.jsxs("span",{children:["Entities",e.jsx(ke,{name:"entity_count",sort:i,direction:u})]})}),e.jsx("th",{onClick:()=>x("wire_count"),children:e.jsxs("span",{children:["Wires",e.jsx(ke,{name:"wire_count",sort:i,direction:u})]})})]})}),e.jsxs("tbody",{children:[t?.owners.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:5,style:{textAlign:"center"},children:"No owners found in this world"})}),(u>0?a.inorder:a.reverse).map(_=>{const b=a[i][_],j=s[b];return!j||j.brick_count+j.component_count+j.entity_count+j.wire_count===0?null:e.jsxs("tr",{onClick:()=>r(`/players/${b}`),children:[e.jsx("td",{className:"player-name",children:e.jsx("div",{className:"player-name-container",children:e.jsxs("div",{children:[e.jsx("div",{"data-tooltip":j.display_name?"Display Name":"Username",children:j.display_name||j.name}),j.display_name&&e.jsx("div",{className:"username","data-tooltip":"Username",children:j.name})]})})}),e.jsx("td",{style:{textAlign:"right"},children:j.brick_count.toLocaleString()}),e.jsx("td",{style:{textAlign:"right"},children:j.component_count.toLocaleString()}),e.jsx("td",{style:{textAlign:"right"},children:j.entity_count.toLocaleString()}),e.jsx("td",{style:{textAlign:"right"},children:j.wire_count.toLocaleString()})]},b)})]})]})}):null},yg=["Plate","Space","Studio","Peaks"],xg=()=>{const t=dt(te.WorldList),[n,r]=C.useState(""),[s,a]=C.useState(!0),[i,o]=C.useState([]),[u,v]=C.useState(!1),x=Ne(vt),_=Ne(yt),[b,j]=C.useState(!1),P=ie(te.WorldSave),w=ie(te.WorldCreate),m=ie(te.WorldUse),l=ie(te.WorldActive),c=ie(te.WorldNext),d=$u(),[h,y]=Le("/worlds/*?"),p=y?.["*"],{onBack:g,swipeHandlers:f,inspectorOpen:S}=Kt(!!p,"/worlds"),N=Y.useUtils(),O=Y.world.use.useMutation(),R=Y.world.save.useMutation(),M=Y.world.create.useMutation(),D=async()=>{a(!0);const[B,oe,fe]=await Promise.all([N.world.list.fetch(),l?N.world.active.fetch():null,c?N.world.next.fetch():null]);o(B),yt.set(oe),vt.set(fe),a(!1)};C.useEffect(()=>{D()},[]);const q=async()=>{if(v(!0),await O.mutateAsync({})&&(yt.set(null),c)){const oe=await N.world.next.fetch();vt.set(oe)}v(!1)},T=async()=>{v(!0),await R.mutateAsync({}),v(!1)},z=async B=>{v(!0),await R.mutateAsync({name:B}),v(!1),D()},A=async(B,oe)=>{v(!0),await M.mutateAsync({name:B,level:oe}),v(!1),D()},U=B=>B.toLowerCase().includes(n.toLowerCase()),[X,V]=C.useState(null),le=et({title:"Save World As",content:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Enter a name for the new world"}),e.jsx("p",{children:e.jsx(me,{type:"text",placeholder:"World Name",value:X??"",onChange:B=>V(B)})})]}),leftButton:B=>e.jsxs(F,{normal:!0,onClick:()=>B(null),children:[e.jsx(De,{}),"Cancel"]}),rightButton:B=>e.jsxs(F,{disabled:!X,main:!0,onClick:()=>B(X),children:[e.jsx(nt,{}),"Save As"]})}),[de,Q]=C.useState("Plate"),he=et({title:"Create New World",content:e.jsxs(e.Fragment,{children:[e.jsx("p",{children:"Select a name and map for the new world"}),e.jsx("p",{children:e.jsx(me,{type:"text",placeholder:"World Name",value:X??"",onChange:B=>V(B)})}),e.jsx("p",{children:e.jsx(Ua,{value:de,options:yg,onChange:B=>Q(B)})})]}),leftButton:B=>e.jsxs(F,{normal:!0,onClick:()=>B(null),children:[e.jsx(De,{}),"Cancel"]}),rightButton:B=>e.jsxs(F,{disabled:!X,main:!0,onClick:()=>B({name:X,map:de}),children:[e.jsx(nt,{}),"Create"]})});return t?e.jsxs(e.Fragment,{children:[e.jsx(ze,{title:"Worlds",onBack:g,children:(P||w||m)&&e.jsxs("div",{className:"widgets-container worlds",children:[e.jsxs(F,{normal:!0,boxy:!0,"data-tooltip":"Show more world actions",onClick:()=>j(!b),children:[b?e.jsx(_t,{}):e.jsx(St,{}),"Actions"]}),e.jsxs(Ve,{visible:b,children:[P&&e.jsxs(F,{info:!0,disabled:u||!d.started,"data-tooltip":"Save the currently loaded world",onClick:()=>{j(!1),T()},children:[e.jsx(Vt,{}),"Save World"]}),P&&e.jsxs(F,{normal:!0,disabled:u||!d.started,"data-tooltip":"Save a copy of the currently loaded world",onClick:()=>{j(!1),V(null),le.prompt().then(B=>{B&&z(B)})},children:[e.jsx(oh,{}),"Save As"]}),w&&e.jsxs(F,{main:!0,disabled:u||!d.started,"data-tooltip":"Create a new world",onClick:()=>{j(!1),V(null),Q("Plate"),he.prompt().then(B=>{B&&A(B.name,B.map)})},children:[e.jsx(lh,{}),"New World"]}),m&&e.jsxs(F,{normal:_===null,warn:_!==null,disabled:u||!_,"data-tooltip":"Remove the default world for the server (on startup)",onClick:()=>{j(!1),q()},children:[e.jsx(vu,{}),"Clear Default"]})]})]})}),e.jsxs(He,{children:[e.jsx(We,{}),e.jsxs("div",{className:`generic-container worlds-container ${S?"inspector-open":""}`,...f,children:[e.jsxs("div",{className:"worlds-list-container",children:[e.jsxs(we,{children:[e.jsx(me,{type:"text",placeholder:"Search Worlds...",value:n,onChange:B=>r(B)}),e.jsx("span",{style:{flex:1}}),e.jsx(F,{icon:!0,normal:!0,"data-tooltip":"Refresh world list",onClick:D,children:e.jsx(Qt,{})})]}),e.jsxs("div",{className:"worlds-list",children:[e.jsx(Pe,{children:i.map(B=>U(B)&&e.jsxs(xt,{href:"/worlds/"+B,className:`world-item ${B===p?"selected":""} ${B===_?"next":""}`,"data-tooltip":B===_?"This world will load when the server starts":"",children:[B===_?e.jsx(gu,{className:"world-item-active"}):!_&&B===x?e.jsx(ch,{className:"world-item-next"}):e.jsx(fh,{}),B]},B))}),e.jsx(xe,{active:s,size:"huge",children:"Loading Worlds"})]})]}),e.jsxs("div",{className:"world-inspector-container",children:[e.jsx(we,{attached:!0,children:p??"SELECT A WORLD"}),e.jsx("div",{className:"world-inspector",children:e.jsx(gg,{})})]})]})]}),le.children,he.children]}):null},bg=({children:t})=>e.jsx(Y.Provider,{client:Yt,queryClient:xi,children:e.jsxs(Sd,{client:xi,children:[e.jsx(qh,{}),t]})}),jg=()=>e.jsx(bg,{children:e.jsx(wd,{children:e.jsx(Cd,{hook:Rd,children:e.jsxs(Sr,{children:[e.jsx(_e,{path:"/",component:Bf}),e.jsx(_e,{path:"/account",component:Wh}),e.jsx(_e,{path:"/history/:time?",component:Zh}),e.jsx(_e,{path:"/metrics/:view?",component:sp}),e.jsx(_e,{path:"/players/:id?",component:op}),e.jsx(_e,{path:"/plugins/:id?",component:up}),e.jsx(_e,{path:"/server",component:gp}),e.jsx(_e,{path:"/roles/:id?",component:xp}),e.jsx(_e,{path:"/users/:id?",component:wp}),e.jsx(_e,{path:"/worlds/*?",component:xg}),e.jsx(_e,{component:Th})]})})})});id.createRoot(document.getElementById("root")).render(e.jsx(jg,{}));
7
+ //# sourceMappingURL=app-Dfcj6I4Z.js.map