(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[405],{8312:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/",function(){return l(2280)}])},2280:function(e,t,l){"use strict";l.r(t),l.d(t,{default:function(){return j}});var n=l(5893),r=l(7294),a=l(4596);let s=e=>{let t=t=>{let l=e=>e instanceof HTMLAnchorElement&&e.href?e:e instanceof HTMLElement&&e.parentElement?l(e.parentElement):null,n=l(t.target);if(!(n instanceof HTMLAnchorElement))return;let{href:r}=n;r.match(RegExp(`^(http://www.|https://www.|http://|https://)+(${window.location.hostname})`))||e.trackLink({href:r})};(0,r.useEffect)(()=>(window.document.addEventListener("click",t,{capture:!0}),()=>window.document.removeEventListener("click",t,{capture:!0})),[])};var c=function(){let e=(0,r.useContext)(a.Z),t=(0,r.useCallback)(t=>null==e?void 0:e.trackPageView(t),[e]),l=(0,r.useCallback)(t=>null==e?void 0:e.trackEvent(t),[e]),n=(0,r.useCallback)(()=>null==e?void 0:e.trackEvents(),[e]),c=(0,r.useCallback)(t=>null==e?void 0:e.trackSiteSearch(t),[e]),o=(0,r.useCallback)(t=>null==e?void 0:e.trackLink(t),[e]),i=(0,r.useCallback)(()=>{e&&s(e)},[e]),u=(0,r.useCallback)((t,...l)=>{null==e||e.pushInstruction(t,...l)},[e]);return{trackEvent:l,trackEvents:n,trackPageView:t,trackSiteSearch:c,trackLink:o,enableLinkTracking:i,pushInstruction:u}},o=l(9008),i=l.n(o),u=l(4123);let p=()=>{let[e,t]=(0,r.useState)(""),{theme:l}=(0,u.F)();return(0,r.useEffect)(()=>{t(window.location.hostname)},[]),(0,n.jsxs)("div",{children:[(0,n.jsx)("span",{style:{color:l.yellow},children:"guest"}),(0,n.jsx)("span",{style:{color:l.white},children:"@"}),(0,n.jsx)("span",{style:{color:l.green},children:e}),(0,n.jsx)("span",{style:{color:l.white},children:":$ ~"})]})},d=e=>{let{history:t}=e;return(0,n.jsx)(n.Fragment,{children:t.map((e,t)=>(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex flex-row space-x-2",children:[(0,n.jsx)("div",{className:"flex-shrink",children:(0,n.jsx)(p,{})}),(0,n.jsx)("div",{className:"flex-grow",children:e.command})]}),(0,n.jsx)("p",{className:"whitespace-pre-wrap mb-2",style:{lineHeight:"normal"},dangerouslySetInnerHTML:{__html:e.output}})]},e.command+t))})};var f=l(7109);let h=e=>{let t=["clear",...Object.keys(f)];return -1!==t.indexOf(e.split(" ")[0])};var m=l(2321);let x=(e,t)=>{let l=Object.keys(f).filter(t=>t.startsWith(e));1===l.length&&t(l[0])},g=(e,t,l)=>{let n=e.split("\n");t>n.length-1&&(t=0);let r=/style="(.*?)"/gm;return[(n=(n=n.map(e=>e.replace(/<span >/g,"").replace(/<span>/g,"").replace(/<\/span>/g,"").replace(r,""))).map((e,n)=>n===t?'<span style="background: '.concat(l.foreground,"; color: ").concat(l.background,'">').concat(e,"</span>"):"<span>".concat(e,"</span>"))).join("\n"),++t]},w=e=>{let{history:t}=e;return t?(0,n.jsx)(n.Fragment,{children:(0,n.jsx)("div",{children:(0,n.jsx)("p",{className:"whitespace-pre-wrap mb-2",style:{lineHeight:"normal"},dangerouslySetInnerHTML:{__html:t.output}})})}):null},v=e=>{let{inputRef:t,containerRef:l}=e,{trackEvent:a}=c(),{theme:s}=(0,u.F)(),[o,i]=(0,r.useState)(""),[d,v]=(0,r.useState)(0),{setCommand:k,setDynamicCommand:y,setDynamicHistory:j,history:E,dynamicHistory:b,lastCommandIndex:C,setLastCommandIndex:_,clearHistory:N,clearDynamicHistory:L}=(0,m.S)();(0,r.useEffect)(()=>{l.current.scrollTo(0,l.current.scrollHeight)},[E,b]),(0,r.useEffect)(()=>{""===o&&L()},[o]);let S=async e=>{y(e.target.value),i(e.target.value)},T=async e=>{let t=E.map(e=>{let{command:t}=e;return t}).filter(e=>e);if("c"===e.key&&e.ctrlKey)e.preventDefault(),i(""),y(""),L();else if("l"===e.key&&e.ctrlKey)e.preventDefault(),N(),L();else if("Tab"===e.key){if(e.preventDefault(),x(o,i),null!==b){let e=g(b.output,d,s);j(e[0]),v(e[1])}}else if("Enter"===e.key||"13"===e.code){if(e.preventDefault(),null!==b&&"search"===o.split(" ")[0]&&0!==d){let e=b.output.split("\n"),t=RegExp("(?<=<a.*>)[^<]*(?=<\\/a>)");await (0,f.search)(e[d-1].match(t)[0].split(" "))}_(0),k(o),y(""),i(""),v(0),a({category:"Command Executed",action:o||"no command"})}else if("ArrowUp"===e.key){if(e.preventDefault(),!t.length)return;let l=C+1;l<=t.length&&(_(l),i(t[t.length-l]))}else if("ArrowDown"===e.key){if(e.preventDefault(),!t.length)return;let l=C-1;l>0?(_(l),i(t[t.length-l])):(_(0),i(""))}else v(0)};return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{className:"flex flex-row space-x-2",children:[(0,n.jsx)("label",{htmlFor:"prompt",className:"flex-shrink",children:(0,n.jsx)(p,{})}),(0,n.jsx)("input",{ref:t,id:"prompt",type:"text",className:"focus:outline-none flex-grow","aria-label":"prompt",style:{backgroundColor:s.background,color:h(o)||""===o?s.green:s.red},value:o,onChange:e=>S(e),autoFocus:!0,onKeyDown:T,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off"})]}),(0,n.jsx)(w,{history:b})]})};var k=l(1181);let y=e=>{let{inputRef:t}=e,{trackPageView:l}=c(),{history:a}=(0,m.S)(),{theme:s}=(0,u.F)(),o=r.useRef(null);return r.useEffect(()=>{l({})},[]),r.useEffect(()=>{t.current&&t.current.focus()},[a]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i(),{children:(0,n.jsx)("title",{children:"CLI Startpage"})}),(0,n.jsx)("div",{className:"overflow-hidden h-full rounded",style:{borderColor:s.yellow,padding:k.Cg?16:8,borderWidth:k.Cg?2:0},children:(0,n.jsxs)("div",{ref:o,className:"overflow-y-auto h-full",children:[(0,n.jsx)(d,{history:a}),(0,n.jsx)(v,{inputRef:t,containerRef:o})]})})]})};var j=y}},function(e){e.O(0,[774,888,179],function(){return e(e.s=8312)}),_N_E=e.O()}]);