"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[696],{60826:function(e,t,l){l.d(t,{Z:function(){return A}});var r=l(85893),n=l(60),s=l(67294),a=l(5606);let o=[{name:"logs"},{name:"shell"}];function i(e){let{elementRef:t,className:l,options:r,removeIntersected:n,delay:a,elId:o}=e,i=(0,s.useRef)(null),[u,c]=s.useState(!1),[d,m]=s.useState(0),v=a||200,f=s.useCallback((e,t)=>{let l=e[0];window.clearTimeout(i.current),l.isIntersecting?i.current=setTimeout(()=>{c(!0),n&&t.unobserve(l.target)},v):c(!1)},[]);return s.useEffect(()=>{let e=o?document.getElementById(o):null==t?void 0:t.current,n=l?document.querySelectorAll(".".concat(l)):null;if(!e&&!l&&d<5){requestAnimationFrame(()=>{setTimeout(()=>{m(d+1)},2e3)});return}let s=new IntersectionObserver(f,{rootMargin:"0px 0px 0px 0px",...r});n?n.forEach(e=>{s.observe(e)}):e&&s.observe(e)},[d]),{isIntersecting:u}}var u=l(71077),c=l(96486),d=l.n(c),m=l(76242),v=l(57493),f=l(98388);function p(e){let{spacing:t,componentRef:l,...n}=e;return(0,r.jsx)("div",{...n,className:(0,f.m6)("relative flex items-center gap-2 border border-solid rounded-default","border-slate-200 dark:border-white/10",t?"normal"==t?"px-3 py-2":"tight"==t?"px-2 py-1":"":"px-3 py-2","twui-border",n.className),ref:l,children:n.children})}var h=l(36969),x=l(25808),g=l(94495),w=l(94655),j=l(3668);function b(e){let{url:t,wrapperProps:l,title:a,...o}=e,{loading:i,setLoading:u}=(0,x.Z)();return(0,r.jsx)(p,{...l,className:(0,f.m6)("p-0",null==l?void 0:l.className),children:(0,r.jsxs)(n.Z,{className:"gap-0",children:[(0,r.jsxs)(w.Z,{className:"p-4 w-full justify-between",children:[(0,r.jsx)(w.Z,{children:a?(0,r.jsx)(s.Fragment,{children:(0,r.jsx)(j.Z,{size:"small",variant:"faded",children:a})}):null}),(0,r.jsxs)(w.Z,{children:[(0,r.jsx)(g.Z,{title:"Open Full Screen",variant:"ghost",className:"p-1!",onClick:()=>{window.open(t,"__blank")},children:(0,r.jsx)(h.Z,{name:"ArrowUpRight",size:20})}),(0,r.jsx)(g.Z,{title:"Refresh Iframe",variant:"ghost",className:"p-1!",loading:i,onClick:()=>{u(!0),setTimeout(()=>{u(!1)},2e3)},loadingProps:{size:"smaller"},children:(0,r.jsx)(h.Z,{name:"RotateCcw",size:18})})]})]}),(0,r.jsx)("hr",{}),i?(0,r.jsx)(v.Z,{className:"w-full p-10 h-[400px]",children:(0,r.jsx)(m.Z,{})}):(0,r.jsx)("iframe",{...o,src:t,className:(0,f.m6)("w-full h-[400px]",o.className)})]})})}function N(e){let{service:t,server:l,target:o,log_cmd:c,portRef:f}=e,{pageProps:p,ws:h}=(0,s.useContext)(a.AppContext),g=(0,s.useRef)(void 0),{data:w}=(0,u.Z)(),{isIntersecting:j}=i({elementRef:g,options:{rootMargin:"-200px",threshold:0}}),[N,Z]=(0,s.useState)(),{refresh:k,setRefresh:C}=(0,x.Z)(),y=(0,s.useRef)(!1);function E(){(null==N?void 0:N.port)&&h.sendData({event:"client:kill-port",server:l,service:d().omit(t,["servers"]),port:N.port})}(0,s.useEffect)(()=>{if((null==h?void 0:h.socket)&&!y.current&&j)return"logs"==o?h.sendData({event:"client:service-server-logs",server:l,service:d().omit(t,["servers"]),cmd:c}):h.sendData({event:"client:service-server-shell",server:l,service:d().omit(t,["servers"])}),y.current=!0,function(){E()}},[h,k,j]),(0,s.useEffect)(()=>{y.current&&(E(),Z(void 0),y.current=!1,C(e=>e+1))},[o,c]),(0,s.useEffect)(()=>{var e,t,r;!N&&((null==w?void 0:w.event)=="server:service-server-logs"&&(null==w?void 0:w.ttyd)&&(null===(e=w.server)||void 0===e?void 0:e.private_ip)==l.private_ip&&setTimeout(()=>{Z(w.ttyd)},2e3),(null==w?void 0:w.event)=="server:service-server-shell"&&(null==w?void 0:w.ttyd)&&(null===(t=w.server)||void 0===t?void 0:t.private_ip)==l.private_ip&&setTimeout(()=>{Z(w.ttyd)},2e3),f&&(null==w?void 0:null===(r=w.ttyd)||void 0===r?void 0:r.port)&&(f.current=w.ttyd.port))},[w]),(0,s.useEffect)(()=>{(null==N?void 0:N.port)&&(j?(y.current=!1,Z(void 0)):E())},[j]);let R=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("code",{children:l.private_ip})," ",o]});return(0,r.jsxs)(n.Z,{className:"gap-0 w-full",componentRef:g,children:[j&&(null==N?void 0:N.url)&&N.port?(0,r.jsx)(n.Z,{className:"gap-0",children:(0,r.jsx)(b,{url:null==N?void 0:N.url,title:R,wrapperProps:{className:"border-none"}})}):(0,r.jsx)(v.Z,{className:"p-10 h-[460px]",children:(0,r.jsx)(m.Z,{})}),(0,r.jsx)("hr",{})]})}var Z=l(73935),k=l(62190),C=l(84681);function y(e){let{open:t,setOpen:l,...n}=e;return t?Z.createPortal((0,r.jsxs)("div",{className:(0,f.m6)("fixed z-[200] top-0 left-0 w-screen h-screen","flex flex-col items-center justify-center p-4","twui-modal-root"),role:"dialog","aria-modal":"true",children:[(0,r.jsx)("div",{className:(0,f.m6)("absolute top-0 left-0 bg-dark/80 z-0","w-screen h-screen"),onClick:e=>{l(!1)}}),(0,r.jsxs)(C.Z,{...d().omit(n,["targetWrapperProps"]),className:(0,f.m6)("z-10 max-w-modal bg-background-light dark:bg-background-dark","w-full relative max-h-[95vh] overflow-y-auto","twui-modal-content",n.className),children:[n.children,(0,r.jsx)(g.Z,{className:"absolute top-0 right-0 p-2",variant:"ghost",color:"gray",onClick:()=>{l(!1)},title:"Close Modal Button",children:(0,r.jsx)(k.Z,{size:30})})]})]}),document.getElementById("twui-modal-root")):null}var E=l(20528);function R(e){let t,{open:l,setOpen:n,targetElRef:a,position:o="bottom",trigger:i="hover",debounce:u,popoverTargetActiveRef:c,popoverContentActiveRef:m,popoverReferenceRef:v,isPopover:p,...h}=e;if(!l)return null;let[x,g]=s.useState({});s.useEffect(()=>{l&&(null==a?void 0:a.current)&&g(function(e){let{position:t,targetElRef:l}=e;if(!l.current)return{};let r=l.current.getBoundingClientRect(),n=window.getComputedStyle(l.current),s=(0,E.Z)(n.paddingRight),a={position:"absolute",zIndex:100},o={top:r.bottom+window.scrollY+8,left:r.left+window.scrollX+r.width/2,transform:"translateX(-50%)"},i={bottom:window.innerHeight-(r.top+window.scrollY)+8,left:r.left+window.scrollX+r.width/2,transform:"translateX(-50%)"};return"bottom"===t?a=d().merge(a,o):"bottom-left"===t?a=d().merge(a,d().omit(o,["transform"]),{left:r.left}):"bottom-right"===t?a=d().merge(a,d().omit(o,["left","transform"]),{right:window.innerWidth-(r.left+window.scrollX)-r.width-s}):"top"===t?a=d().merge(a,i):"right"===t?(a.top=r.top+window.scrollY+r.height/2,a.left=r.right+window.scrollX+8,a.transform="translateY(-50%)"):"left"===t&&(a.top=r.top+window.scrollY+r.height/2,a.right=window.innerWidth-(r.left+window.scrollX)+8,a.transform="translateY(-50%)"),a}({position:o,targetElRef:a}))},[l,a,o]);let w=s.useCallback(()=>{m.current=!0,c.current=!1,n(!0)},[]),j=s.useCallback(()=>{window.clearTimeout(t),t=setTimeout(()=>{if(c.current){c.current=!1;return}n(!1)},u)},[]);return l?Z.createPortal((0,r.jsx)(C.Z,{...h,className:(0,f.m6)("max-w-[300px] z-[250]","twui-popover-content",h.className),style:{...x,...h.style},onMouseEnter:"hover"===i?w:h.onMouseEnter,onMouseLeave:"hover"===i?j:h.onMouseLeave,role:"dialog","aria-modal":"true",children:h.children}),document.getElementById("twui-popover-root")):null}function z(e){let t;let{target:l,targetRef:n,targetWrapperProps:a,open:o,setOpen:i,isPopover:u,popoverReferenceRef:c,trigger:d="hover",debounce:m=500,onClose:v,hoverOpen:p}=e,[h,x]=s.useState(!1),[g,w]=s.useState(o||!1);s.useEffect(()=>{let e=u?"twui-popover-root":"twui-modal-root",t=document.getElementById(e);if(t)u&&(t.style.zIndex="1000"),x(!0);else{let t=document.createElement("div");t.id=e,document.body.appendChild(t),x(!0)}},[]),s.useEffect(()=>{null==i||i(g),!1==g&&(null==v||v())},[g]),s.useEffect(()=>{w(o||!1)},[o]);let j=n||s.useRef(null),b=c||j,N=s.useRef(!1),Z=s.useRef(!1),k=s.useCallback(t=>{var l;N.current=!0,Z.current=!1,w(!0),null===(l=e.onMouseEnter)||void 0===l||l.call(e,t)},[]),C=s.useCallback(l=>{var r;window.clearTimeout(t),t=setTimeout(()=>{if(Z.current){Z.current=!1;return}w(!1)},m),null===(r=e.onMouseLeave)||void 0===r||r.call(e,l)},[]),E=s.useCallback(e=>{let t=e.target,l=t.closest(".twui-popover-content");if(!t.closest(".twui-popover-target")&&!l)return w(!1)},[]);return s.useEffect(()=>{if(u)return document.addEventListener("click",E),()=>{document.removeEventListener("click",E)}},[]),(0,r.jsxs)(s.Fragment,{children:[l?(0,r.jsx)("div",{...a,onClick:e=>{e.preventDefault(),e.stopPropagation(),w(!g)},ref:j,onMouseEnter:u&&("hover"===d||p)?k:null==a?void 0:a.onMouseEnter,onMouseLeave:u&&("hover"===d||p)?C:null==a?void 0:a.onMouseLeave,className:(0,f.m6)("twui-popover-target",null==a?void 0:a.className),children:l}):null,h?u?(0,r.jsx)(R,{...e,open:g,setOpen:w,targetElRef:b,debounce:m,popoverTargetActiveRef:N,popoverContentActiveRef:Z}):(0,r.jsx)(y,{...e,open:g,setOpen:w}):null]})}function S(e){let{...t}=e;return(0,r.jsx)("h3",{...t,className:(0,f.m6)("text-xl mb-4","twui-headings twui-heading","twui-h3",t.className),children:t.children})}var M=l(77827);function _(e){let{componentRef:t,...l}=e;return(0,r.jsx)(M.Z,{istextarea:!0,...l,componentRef:t})}function T(e){let{setLog:t}=e,{open:l,setOpen:a}=(0,x.Z)(),o=(0,s.useRef)("");return(0,r.jsx)(z,{target:(0,r.jsx)(g.Z,{title:"Enter custom command",size:"small",color:"gray",className:"w-[42px] h-[42px]",children:(0,r.jsx)(h.Z,{name:"Edit3",size:14})}),setOpen:a,open:l,children:(0,r.jsxs)(n.Z,{children:[(0,r.jsxs)(n.Z,{className:"gap-1",children:[(0,r.jsx)(S,{className:"admin-h3",children:"Enter a custom Command"}),(0,r.jsx)(j.Z,{variant:"faded",children:"Enter a command to run a custom log"})]}),(0,r.jsx)(_,{placeholder:"Enter custom command",changeHandler:e=>{o.current=e},autoFocus:!0}),(0,r.jsx)(g.Z,{title:"Set Custom Command",onClick:()=>{t(o.current.trim()),a(!1)},children:"Set Custom Command"})]})})}var L=l(3326);function I(e){let{service:t,setLog:l,log:n}=e,a=t.logs,o=null==a?void 0:a.map(e=>"string"==typeof e?e:e.cmd),i=(null==n?void 0:n.match(/./))&&!(null==o?void 0:o.find(e=>e==n));return(0,r.jsx)(s.Fragment,{children:i?(0,r.jsx)(w.Z,{className:"grow",children:(0,r.jsx)(p,{className:"w-full py-1 h-[42px]",children:(0,r.jsxs)(w.Z,{className:"w-full justify-between",children:[(0,r.jsx)(j.Z,{children:n}),(0,r.jsx)(g.Z,{title:"Clear Custom Log",variant:"ghost",className:"p-1",onClick:()=>{l(void 0)},children:(0,r.jsx)(k.Z,{size:17})})]})})}):(0,r.jsx)(L.Z,{options:[...(null==o?void 0:o.map(e=>({value:e,title:e})))||[]],changeHandler:e=>{l(e)}})})}function F(e){let{service:t,setLog:l,log:s}=e;return(0,r.jsx)(n.Z,{className:"w-full gap-2 p-4",children:(0,r.jsxs)(w.Z,{className:"flex-nowrap",children:[(0,r.jsx)(T,{setLog:l}),(0,r.jsx)(I,{service:t,setLog:l,log:s})]})})}function A(e){var t;let{service:l,server:u,wrapperProps:c,portRef:d}=e,{pageProps:m}=(0,s.useContext)(a.AppContext),{isIntersecting:v}=i({elementRef:(0,s.useRef)(void 0)}),[p,h]=(0,s.useState)((null===(t=l.logs)||void 0===t?void 0:t[0])?"logs":"shell"),[x,j]=(0,s.useState)();return(0,r.jsxs)(n.Z,{...c,className:(0,f.m6)("gap-0",null==c?void 0:c.className),children:[(0,r.jsxs)(w.Z,{className:"w-full justify-between p-4 -mb-6",children:[(0,r.jsx)(w.Z,{children:(0,r.jsx)("code",{children:u.private_ip})}),(0,r.jsx)(w.Z,{className:"",children:o.map((e,t)=>{let l=e.name==p;return(0,r.jsx)(g.Z,{title:"".concat(e.name),onClick:()=>{h(e.name)},size:"smaller",color:"gray",variant:l?void 0:"outlined",children:e.name},t)})})]}),"logs"==p?(0,r.jsx)(F,{server:u,service:l,setLog:j,log:x}):(0,r.jsx)(w.Z,{className:"h-[74px]"}),(0,r.jsx)("hr",{}),(0,r.jsx)(N,{server:u,service:l,target:p,portRef:d,log_cmd:x})]})}},3326:function(e,t,l){l.d(t,{Z:function(){return f}});var r=l(85893),n=l(42171),s=l(74598),a=l(67294),o=l(98388),i=l(59123),u=l(6531),c=l(3668),d=l(60);function m(e,t,l){let r=t||"-";try{if(!e)return"";let t=String(e).trim().toLowerCase().replace(/ {2,}/g," ").replace(/ /g,r).replace(/[^a-z0-9]/g,r).replace(/-{2,}|_{2,}/g,r).replace(/^-/,"");if(l)return t;return t.replace(/-$/,"")}catch(e){return""}}var v=l(38249);function f(e){var t,l,f;let{label:p,options:h,componentRef:x,labelProps:g,wrapperProps:w,showLabel:j,iconProps:b,changeHandler:N,info:Z,validateValueFn:k,wrapperWrapperProps:C,dispatchState:y,...E}=e,[R,z]=a.useState({isValid:!0}),S=x||a.useRef(null),[M,_]=a.useState({value:null===(t=h[0])||void 0===t?void 0:t.value,data:null===(l=h[0])||void 0===l?void 0:l.data});a.useEffect(()=>{setTimeout(()=>{requestAnimationFrame(()=>{var e;let t=null===(e=S.current)||void 0===e?void 0:e.value;t&&k&&k(t).then(e=>{z(e)})})},200)},[]),a.useEffect(()=>{null==y||y(M.data)},[M]);let T=p?m(p):E.name?m(E.name):E.title?m(E.title):"select-".concat(Math.round(1e6*Math.random()));return(0,r.jsxs)(d.Z,{...C,className:(0,o.m6)("gap-1",null==C?void 0:C.className),children:[(0,r.jsxs)("div",{...w,className:(0,o.m6)("relative w-full flex items-center border rounded-default","border-slate-300 dark:border-white/20 pr-2","focus:border-slate-700 dark:focus:border-white/50","outline-slate-300 dark:outline-white/20","focus:outline-slate-700 dark:focus:outline-white/50","bg-white dark:bg-background-dark",R.isValid?"":"outline-warning border-warning",null==w?void 0:w.className),children:[j&&(0,r.jsx)("label",{htmlFor:T,...g,className:(0,o.m6)("text-xs absolute -top-2.5 left-2 text-foreground-light/80 bg-background-light","dark:text-foreground-dark/70 dark:bg-background-dark px-1.5 rounded-t","twui-input-label",null==g?void 0:g.className),children:p||E.title||E.name}),(0,r.jsx)("select",{id:T,"aria-label":E["aria-label"]||E.title,...E,className:(0,o.m6)("w-full pl-3 py-2 rounded-default appearance-none pr-8","grow !border-none !outline-none","twui-select",E.className),ref:S,value:(null===(f=h.flat().find(e=>e.default))||void 0===f?void 0:f.value)||void 0,onChange:e=>{var t;let l=h.find(t=>t.value==e.target.value);l&&_(l),null==N||N(e.target.value,null==l?void 0:l.data),null===(t=E.onChange)||void 0===t||t.call(E,e),null==k||k(e.target.value).then(e=>{z(e)})},children:h.flat().map((e,t)=>{let l=e.title||(0,v.Z)(e.value);return(0,r.jsx)("option",{value:e.value,children:l},t)})}),(0,r.jsx)(n.Z,{size:20,...b,className:(0,o.m6)("pointer-events-none -ml-6",null==b?void 0:b.className)}),Z&&(0,r.jsx)(i.Z,{target:(0,r.jsx)("div",{title:"Select Info Button",children:(0,r.jsx)(s.Z,{size:20})}),hoverOpen:!0,children:(0,r.jsx)(u.Z,{className:"min-w-[250px] p-6",children:"string"==typeof Z?(0,r.jsx)(c.Z,{children:Z}):Z})})]}),!R.isValid&&R.msg?(0,r.jsx)(c.Z,{size:"smaller",className:"text-warning",children:R.msg}):void 0]})}},57493:function(e,t,l){l.d(t,{Z:function(){return s}});var r=l(85893),n=l(98388);function s(e){let{...t}=e;return(0,r.jsx)("div",{...t,className:(0,n.m6)("flex flex-col items-center justify-center gap-4 p-2 w-full","h-full twui-center",t.className),children:t.children})}},56211:function(e,t,l){l.d(t,{Z:function(){return s}});var r=l(85893),n=l(98388);function s(e){let{...t}=e;return(0,r.jsx)("h2",{...t,className:(0,n.m6)("text-2xl md:text-3xl mb-4","twui-headings twui-heading","twui-h2",t.className),children:t.children})}}}]);