console.log("nebula#~ floatingWindows.js");let MultitaskingMoveHints=["Move your window somewhere cozy.","Give it a neat little spot.","What about bottom-left?","This place is too cold, move me somewhere warm!"],MultitaskingResizeHints=["Let go to continue being productive.","All sizes are in stock!","One size, fits most*."];function MultitaskingOpen(e){var t=0,n=0,i=0,o=0;const a="MultitaskingFrame-"+Date.now();var l=document.createElement("div");l.id=a,document.body.appendChild(l),l.innerHTML=`
    <div class="nebula-frame-container">
      <div class="nebula-frame-controls">
        <button class="nebula-frame-control close-button" onclick="closeWindow('${a}')">
          <i class="bi bi-x"></i>
        </button>
      </div>
      <div class="nebula-frame-spinner-container">
        <div class="nebula-frame-spinner"></div>
      </div>
      <iframe
        src="${e}?multitasking=true"
        class="nebula-frame"
        id="${a}-Frame"
      ></iframe>
      <div class="nebula-frame-focus" onclick="focusWindow('${a}')"></div>
      <div class="nebula-frame-resizing-trap"></div>
      <div class="nebula-frame-resize-text-hint">
        <p style="font-size: 34px"><i class="bi bi-textarea-resize"></i></p>
        <p class="nebula-frame-resize-hint-content">  
          There was supposed to be quirky hint here but an unexpected error prevented it from appearing.
        </p>
      </div>
      <div class="nebula-frame-controls-hint">
        <p style="font-size: 34px"><i class="bi bi-arrows-move"></i></p>
        <p class="nebula-frame-move-hint-content">  
          There was supposed to be quirky hint here but an unexpected error prevented it from appearing.
        </p>
      </div>
    </div>
  `;const s=document.querySelector(`#${a} .nebula-frame-container > iframe.nebula-frame`),r=l.querySelector(".nebula-frame-container > .nebula-frame-spinner-container"),c=l.querySelector(".nebula-frame-container .nebula-frame-controls"),u=l.querySelector(".nebula-frame-controls-hint"),m=document.querySelector(`#${a} .nebula-frame-container`),d=m.querySelector(".nebula-frame-resizing-trap");m.style.setProperty("--frameWidth","700px"),m.style.setProperty("--frameHeight","450px"),window.InitialFrameHeight=450,m.style.transition="height .4s, scale .2s linear, opacity .4s",setTimeout(()=>{m.style.scale=1,m.style.opacity=1},50);let y=setTimeout(()=>{});InitializeFrameResize(a);const p=setInterval(()=>{try{s.contentDocument.querySelector("section.fade-appear-done.fade-enter-done")&&(s.style.opacity=1,clearInterval(p),setTimeout(()=>{r.style.opacity=0},500))}catch{}},400);function f(e){e.preventDefault(),null!=dragInitial&&0!=dragInitial||(clearTimeout(y),dragInitial=!0,u.style.opacity=1,d.style.display="block",m.style.setProperty("--frameHeight","225px"),c.style.height="100%",s.style.opacity=0,r.style.opacity=0,m.style.transition="height .4s, scale .3s linear, opacity .3s, background-color .2s",setTimeout(()=>{m.style.backgroundColor="var(--pageSecondary)"},20)),t=i-e.clientX,n=o-e.clientY,i=e.clientX,o=e.clientY,m.style.top=m.offsetTop-n+"px",m.style.left=m.offsetLeft-t+"px",m.offsetTop-n<12&&(m.style.top="12px"),m.offsetTop-n>window.innerHeight-40&&(m.style.top=window.innerHeight-40+"px"),m.offsetLeft<12&&(m.style.left="12px"),m.offsetLeft-t>window.innerWidth-m.clientWidth-12&&(m.style.left=window.innerWidth-m.clientWidth-12+"px")}function h(){document.onmousemove=null,document.onmouseup=null,dragInitial=!1,d.style.display="none",m.style.setProperty("--frameHeight",window.InitialFrameHeight),c.style.height="50px",m.style.backgroundColor="var(--pageBackground)",s.style.opacity=1,u.style.opacity=0,y=setTimeout(()=>{m.style.transition="",u.style.display="none"},400)}c.onmousedown=function(e){e.preventDefault();var t=MultitaskingMoveHints[Math.floor(Math.random()*MultitaskingMoveHints.length)];m.querySelector(".nebula-frame-controls-hint > .nebula-frame-move-hint-content").innerHTML=t,i=e.clientX,o=e.clientY,focusWindow(a),"225px"!=(t=getComputedStyle(m).getPropertyValue("--frameHeight"))&&(window.InitialFrameHeight=t),dragInitial=!1,u.style.opacity=0,u.style.display="block",document.onmousemove=f,document.onmouseup=h},s.contentDocument.window.onmousedown=focusWindow(a)}function focusWindow(e){document.querySelectorAll(".nebula-frame-container").forEach(e=>{e.style.zIndex=99,e.querySelector(".nebula-frame-focus").style.opacity=0,e.querySelector(".nebula-frame-focus").style.display="block",setTimeout(()=>{e.querySelector(".nebula-frame-focus").style.opacity=1},100)});const t=document.querySelector(`#${e} .nebula-frame-container`);t.style.zIndex=100,t.querySelector(".nebula-frame-focus").style.opacity=0,setTimeout(()=>{t.querySelector(".nebula-frame-focus").style.display="none"},100)}function closeWindow(e){const t=document.getElementById(e);var n=document.querySelector(`#${e} .nebula-frame-container`);n.style.scale=.8,n.style.opacity=0,n.style.transition="height .4s, scale .3s linear, opacity .3s",setTimeout(()=>{t.remove()},250)}function InitializeFrameResize(e){const n=document.querySelector(`#${e} .nebula-frame-container`),i=n.querySelector(".nebula-frame-resizing-trap"),o=document.getElementById(e+"-Frame"),a=n.querySelector(".nebula-frame-resize-text-hint");let l=setTimeout(()=>{});n.className=n.className+" nebula-frame-resizable";var s,r,c,u,t=document.createElement("div"),m=document.createElement("div");function d(e){c+e.clientX-s<=500?n.style.setProperty("--frameWidth","500px"):n.style.setProperty("--frameWidth",c+e.clientX-s+"px"),u+e.clientY-r<=226?n.style.setProperty("--frameHeight","226px"):n.style.setProperty("--frameHeight",u+e.clientY-r+"px")}function y(e){document.documentElement.removeEventListener("mousemove",d,!1),document.documentElement.removeEventListener("mouseup",y,!1),o.style.position="absolute",o.style.width="var(--frameWidth)",o.style.height="calc(var(--frameHeight) - 50px)",n.style.transition="background-color .2s",clearTimeout(fadeOutTimeout),setTimeout(()=>{n.style.backgroundColor="var(--pageBackground)",o.style.transition="height .4s, opacity .3s",o.style.opacity=1},10),a.style.opacity=0,l=setTimeout(()=>{a.style.display="none"},400),i.style.display="none"}t.className="nebula-frame-resizer",m.className="nebula-frame-resize-hint",n.appendChild(t),n.appendChild(m),t.addEventListener("mousedown",function(e){e.preventDefault();var t=MultitaskingResizeHints[Math.floor(Math.random()*MultitaskingResizeHints.length)];n.querySelector(".nebula-frame-resize-text-hint > .nebula-frame-resize-hint-content").innerHTML=t,n.style.backgroundColor="var(--pageSecondary)",n.style.transition="",clearTimeout(l),a.style.display="block",a.style.opacity=1,s=e.clientX,r=e.clientY,c=parseInt(document.defaultView.getComputedStyle(n).width,10),u=parseInt(document.defaultView.getComputedStyle(n).height,10),document.documentElement.addEventListener("mousemove",d,!1),document.documentElement.addEventListener("mouseup",y,!1),o.style.transition="opacity .2s",o.style.opacity=0,fadeOutTimeout=setTimeout(()=>{o.style.position="fixed",o.style.height=0,o.style.width=0},300),i.style.display="block"},!1)}